3 ms·
A lot of times I just use a simple React class. The author’s lookup map to return a lookup of other hooks, yikes. A class component would probably solve that in
by runawaybottle 7y ago
A lot of times I just use a simple React class. The author’s lookup map to return a lookup of other hooks, yikes. A class component would probably solve that in a more predictable way.
Don’t feel dirty for doing things simply. If your functional component has entire lookup maps for hooks, it’s probably too complicated as a standalone functional component to drop hooks in.
- efdee 7y agoIt's hard to reason about without an actual real-life use case, but the lookup thing he's doing looks extremely convoluted to me.
- draw_down 7y agoAgree, I don’t know what is going on there but it sure smells like something you shouldn’t need to do.
- WorldMaker 7y agoRight, I'd be curious to know a lot more details of the real-life use case that inspired that. My gut feeling says that there's maybe a state machine of some sort which could possibly be split into a sequence or maybe hierarchy of smaller components, but it's hard to tell specifically what the alternative might be without more details on why they thought a lookup table might be useful.
- jiofih 7y agoOnce you start using Context everything has to become a hook to be able to consume it, I bet that’s what’s goin on there.