Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Why React Context Is Not a “State Management” Tool (isquaredsoftware.com)
2 points by magneticz on Dec 1, 2021 | hide | past | favorite | 2 comments


This is a great example of how fast the culture of front-end work can move. Back in January, someone took a lot of time to write all this up because Context and hooks were still somewhat new. But today, almost a year later, it feels like a really long-winded way of getting to the quick, short answer most people use today - "useReducer is the answer, but look at Redux if your app gets overwhelming."


Hi, I wrote this post (but did not submit it).

I have answered this question hundreds of times over the last several years, on Reddit, HN, Stack Overflow, Twitter, and Reactiflux. Literally, we still see many people ask _every single day_ "Context vs Redux?" I finally got fed up with repeating myself over and over and took the time to write a definitive post on the subject.

Context and hooks are not "new". React Context in its current form came out in React 16.3 in March 2018. The hooks API was announced at ReactConf in October 2018, and hit final release in React 16.8 in early 2019.

Nothing about the technical situation in React related to these APIs has changed this year, and everything I wrote is still 100% applicable.

The only thing that will _potentially_ change at some point down the road is when the React team finally tackles finishing up the "context selectors" API they've proof-of-concepted. That will at least fix the primary issues with context updates causing all consuming components to re-render, but still does not change the fact that context itself does not "manage" anything - it's just a conduit for whatever value you put into it. And _that_ more than anything else is what this post is meant to clarify, because _soooo_ many people are confused on that point.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: