3 ms·
I guess then I have no idea why Redux is so widely used, given now the Context API exists.
by applecrazy 8y ago
I guess then I have no idea why Redux is so widely used, given now the Context API exists.
- alexkoeh 8y agoRedux the library is not "state management for react". It's more of a concept that gives you a predictable structure around how state changes over time. I think what you're thinking of is specifically the `react-redux` library which gave a nice abstraction to the old & clunky React context API. The new context API was released with React 16.3 (which came out March of this year).
- acemarke 8y agoMultiple reasons. First, Redux has been around since 2015 (and won the "Flux Wars" that had been going on for a year before that), whereas the new `createContext` API only came out a few months ago. Second, Redux provides a lot more guidance around how you're supposed to structure your application. Context only provides a method for making values available to deeply nested components in the tree. Third, the Redux ecosystem is huge, with addons available for effectively any use case you can think of. [0] Please see my post "Redux - Not Dead Yet!" [1] and Dave Ceddia's post "Redux vs the React Context API" [2] for more details on how they relate. [0] https://blog.isquaredsoftware.com/2017/09/presentation-might-need-redux-ecosystem/ https://blog.isquaredsoftware.com/2017/09/presentation-might... [1] https://blog.isquaredsoftware.com/2018/03/redux-not-dead-yet/ https://blog.isquaredsoftware.com/2018/03/redux-not-dead-yet... [2] https://daveceddia.com/context-api-vs-redux/ https://daveceddia.com/context-api-vs-redux/
- beaconstudios 8y agothe new Context API replaces the `connect()`/`<Provider />` functionality, but not the flux data flow model. Nor does it provide a replacement for the surrounding redux ecosystem - so there's still plenty of benefit to using redux.
- tptacek 8y agoRedux is overused, because of a meme that suggests that the de facto standard React "stack" is React, Redux, and React-Router. That's just a meme (Dan Abramov even wrote a blog post debunking it!) but some memes are hard to fight.
- mikewhy 8y agoThe new Context API can't be used in lifecycle methods, which is a bit of a letdown.