6 ms·
I know that popular opinion in the Twitterverse is that "Redux is dead", but I note that both Twitter and Slack just released major rewrites that use Redux heav
by acemarke 7y ago
I know that popular opinion in the Twitterverse is that "Redux is dead", but I note that both Twitter and Slack just released major rewrites that use Redux heavily.
I talked about Redux usage stats and comparison with other alternatives in my "State of Redux" talk at Reactathon earlier this year [0], and my post "Redux - Not Dead Yet!" also addresses some of these aspects [1].
Also, quick plug for our current focus. I'm working on some tutorials for our new Redux Starter Kit package [2], and then will be working on tackling additional functionality to push it towards a 1.0 release [3].
After that, we'll get started on a major revamp of the Redux docs [4] to improve the learning flow, better organize the content, cover more real-world usage topics, and teach using Redux Starter Kit as the "default way to write Redux".
[0] https://blog.isquaredsoftware.com/2019/03/presentation-state-of-redux/ https://blog.isquaredsoftware.com/2019/03/presentation-state...
[1] https://blog.isquaredsoftware.com/2018/03/redux-not-dead-yet/ https://blog.isquaredsoftware.com/2018/03/redux-not-dead-yet...
[2] https://redux-starter-kit.js.org/ https://redux-starter-kit.js.org/
[3] https://github.com/reduxjs/redux-starter-kit/issues/82 https://github.com/reduxjs/redux-starter-kit/issues/82
[4] https://github.com/reduxjs/redux/issues/3313#issuecomment-450601554 https://github.com/reduxjs/redux/issues/3313#issuecomment-45...
- fooddood 7y agoIsn't the common sentiment now that Redux is no longer considered a must-have for all greenfield projects? Also aren't communication apps a perfect use case for Redux due to the need to have events from multiple sources happen in a single store in a linear order?
- acemarke 7y agoThat's part of what I was getting at, and what I talk about in the first couple links. Lots of folks have used Redux because they were _told_ they "need" to use it. That's always been overkill. And, yes, there are plenty of other viable alternatives that overlap Redux's capabilities in various ways (Apollo, MobX, React context, etc). So sure, it's not a "must-have", because you should _always_ evaluate tools and determine what's really appropriate for your use case rather than just blindly using something. But, at the same time, Redux is still very widely used (~50% of React apps), and not going away. So, there's a big difference between "not an automatic must-have" (which is true) and "dead/dying" (which is not).
- jscheel 7y agoThanks for the articles! We've been using Redux since August of 2016 at Groove. For us, we've found that Redux makes sense when you have state that needs to be shared. If you are dealing with some specific, tightly coupled component state, it sometimes makes sense to keep that particular piece of state local to the component (at least for our use-case). The biggest issues we've run into during our time with Redux have been 1. not being atomic enough with our connected components (sometimes passing massive objects down the component tree instead of selecting what we need at each point), 2. running into leakiness in react-redux (such as function arity changing short-circuit caching behavior in the mapping functions, forgetting to invalidate components when using select factories, etc), and 3. not normalizing our store enough (which contributes to #1). As we continue to mature in Redux, we are slowly fixing #1 and #3 in our codebase. We are still sometimes getting bitten by weirdness in react-redux though. I'm not sure I have a solution, but I think there is still a lot of opportunity for improvement there. And not just in react-redux, in helping developers understand how to properly build performant redux-driven apps in general.
- acemarke 7y agoYep. The Redux "Three Principles" docs page [0] emphasizes the "single source of truth" aspect. It's a good selling point, but has unfortunately led to a lot of folks interpreting that as "you _must_ keep _everything_ in Redux". (Doing so is a valid design decision, and I've certainly talked to folks who deliberately did that to make everything trackable and time-travel-able. But, most UI state probably doesn't need to go in Redux, particularly form state [1].) In reality, there should be a good balance between global and local state. I wrote a Redux FAQ entry that tries to give some rules of thumb for determining what state goes where [2]. When we do the docs revamp, hopefully we can make that kind of thinking more explicit. I'd be very interested in hearing more details on any issues you may be having with React-Redux, and I'm happy to offer advice for you or anyone else on using it better. HN comments aren't a great place for that, but please file an issue for discussion or contact me in the Reactiflux chat channels on Discord in the #redux channel. I'd also greatly appreciate any feedback folks would have on weaknesses with the current docs, so we can improve those issues with the docs revamp. We've had open issues to cover writing a "Performance" docs page for a long time, but no one got around to contributing that, and there's been too many other higher priorities for us to write it. My React/Redux links list does have a section of articles on improving Redux perf [3], if that helps, and there's an FAQ section on that topic [4]. In general, connect more components [5], and use memoized selectors [6] to read data and do transforms. [0] https://redux.js.org/introduction/three-principles https://redux.js.org/introduction/three-principles [1] https://redux.js.org/faq/organizing-state#should-i-put-form-state-or-other-ui-state-in-my-store https://redux.js.org/faq/organizing-state#should-i-put-form-... [2] https://redux.js.org/faq/organizing-state#do-i-have-to-put-all-my-state-into-redux-should-i-ever-use-reacts-setstate https://redux.js.org/faq/organizing-state#do-i-have-to-put-a... [3] https://github.com/markerikson/react-redux-links/blob/master/react-performance.md#redux-performance https://github.com/markerikson/react-redux-links/blob/master... [4] https://redux.js.org/faq/performance https://redux.js.org/faq/performance [5] https://redux.js.org/faq/react-redux#should-i-only-connect-my-top-component-or-can-i-connect-multiple-components-in-my-tree https://redux.js.org/faq/react-redux#should-i-only-connect-m... [6] https://blog.isquaredsoftware.com/2017/12/idiomatic-redux-using-reselect-selectors/ https://blog.isquaredsoftware.com/2017/12/idiomatic-redux-us...
- wootie512 7y agoWhat is the goto for web if Redux is dead? I am not super knowledgeable about all the exact architectures, but I thought mobile was just starting to adopt the redux architecture vs MVP, MVVM, etc
- api_or_ipa 7y agoA lot of people are saying that the new-but-not-really-new React Context API and useReducer hooks are sufficient to cover redux. My team isn't convinced, we see immense value because we're big fans of using Redux Saga-- a model that isn't well covered using Context or hooks, although we do use those APIs as well when needed.
- qudat 7y agoShameless plug: https://github.com/neurosnap/use-cofx https://github.com/neurosnap/use-cofx Under the hood it uses [cofx](https://github.com/neurosnap/cofx https://github.com/neurosnap/cofx) which is a library I wrote to solve the need to write declarative side-effects without redux.
- WorldMaker 7y agoHooks are definitely going to reduce a lot of greenfield project needs for a state library, which should be great for React ease of starting new projects. Something like Redux Saga, Redux Thunks, Redux Observable (my personal preference here), or what have you, are the higher order "toolsets" that Hooks alone aren't likely to replace yet. It may be the case that some of them are going to start targeting Hooks/Context more directly without "needing" an intermediary state engine like Redux, but it's also entirely possible that it will still remain a good reason to make a step change to a state engine like Redux when you find yourself needing higher-order coordination between components that libraries like Sagas, Thunks, or Observables can provide.
- RobertKerans 7y agoSuspense for data loading seems to cover that side of things quite well in the experiments I've tried with the current API. I use Sagas as well though, and Ive found them ok...really easy to test but feel very heavyweight and clunky; personally, I don't _really_ like the loading/error state to be handled by Redux: the more years I work on React/Redux app the more I prefer for a section of an app to be mounted -> triggering a fetch -> loading, show local loading UI -> {fails, show local UI|succeeds, dispatch success}. So Redux becomes a serializable normalized data cache that acts to store the results of disparate API calls and doesn't care at all much about the UI.
- weq 7y ago"Redux" Event Sourcing for the JS hype-machine. Nothing is dead about event sourcing, other then the mob has moved forward in the hype cycle.
- vonseel 7y agoMy only request for redux-starter-kit is more documentation on usage with TypeScript (and perhaps deeper integration with ts-not sure how well the current package integrates with a ts codebase).
- acemarke 7y agoRSK should be fairly usable with TS. As I understand it, it can't be as magically strict as `typesafe-actions` is or infer quite as much automatically, because of how we're generating the action types from the reducer names as strings. But, it should definitely generate correctly typed action creator functions for you. And yes, agree on needing more documentation: https://github.com/reduxjs/redux-starter-kit/issues/59 https://github.com/reduxjs/redux-starter-kit/issues/59 I've got an example app I put together using RSK, our new React-Redux hooks, and TS, and I'm planning to turn that into a tutorial soon: https://github.com/markerikson/rsk-github-issues-experiment https://github.com/markerikson/rsk-github-issues-experiment
- vonseel 7y agoThank you!