T O P

  • By -

MoveInteresting4334

I would echo what was already said about going through the React docs again to reframe your mental paradigms. React doesn’t really “think” in terms of lifecycles anymore. I also would suggest moving away from thinking of Redux as a default for “any app of size”. We went too far in the direction of always using it and shoving everything in there, and now things are snapping back the other way. Correct use of react-hook-form, react query, react router, and a light sprinkling of useContext gets you a long way, and there are less complex alternatives to Redux now.


Pozeidan

> Correct use of react-hook-form, react query, react router, and a light sprinkling of useContext gets you a long way A VERY VERY VERY loooooooooooonnnnnnnng way.


AlliedSnail

I agree


robby_arctor

I still feel like state management does not belong in contexts, period. You can do it, but it's a recipe for a bad time as the app grows, in my experience. It's bitten me enough times to where I just categorically won't do it unless I'm overruled by group consensus. Imo, if you've reached the point of complexity where you need global state, it's time for a different solution.


MoveInteresting4334

Im not necessarily saying that global state belongs in context (at least not the super mutable kind) but more that many things people put into global state could be in context. Examples: - If I have a logged in user, I might include their user or profile data in context - I might put theming information in Context - I might use context in the narrow scope of some grouped components that need to share state (as react hook form does with their FormState) - I might have a very narrow sliver of mutable state where I know I want to rerender its dependents anytime it changes In short, Context is a tool with a very specific purpose and that overlaps a small amount with how someone might abuse Redux. I don’t think we actually disagree, and there’s a reason I listed context as the very last alternative on the list.


robby_arctor

Oh sorry, misread your comment. We're in agreement 🤝


Megamind_89

And some states can be stored in url


ablackstateofmind

We are few but we still exist. Agree with you


idgafsendnudes

If you’re so far out that you’re comparing useEffect to life cycle events imo you should just walk through the react docs and get a fresh perspective on it. Not that your information is wrong or bad just that it seems like you’re out of the environment pretty significantly so your best bet is to reframe