4 ms·
A lot of people have dismissed Redux and even roll their eyes when it's mentioned these days. I'm still a big fan after all these years. The recent improvements
by city41 6y ago
A lot of people have dismissed Redux and even roll their eyes when it's mentioned these days. I'm still a big fan after all these years. The recent improvements such as the toolkit, slices and integration of ImmerJS make Redux much smoother and reduce the boilerplate a lot. For apps that have lots of state, I've yet to find a pattern I like better.
- chrisco255 6y agoDo you have a quick link on what's changed recently? I haven't used the framework in a couple of years.
- city41 6y agoThe biggest improvement IMO is the toolkit, which gives you an off the shelf packaged Redux implementation. The toolkit has support for slices and Immer out of the box. https://redux-toolkit.js.org/ https://redux-toolkit.js.org/
- acemarke 6y agoAs mentioned in a sibling comment: We have a new official "Redux Toolkit" package [0], which is now our recommended way to write Redux logic. It includes utilities to simplify several common Redux use cases, including store setup, defining reducers, immutable update logic, and even creating entire "slices" of state at once. We've also recently added APIs for basic async data fetching via thunks, and reusable functions for managing normalized entity state. Meanwhile, we now recommend the React-Redux hooks API [1] as the default way to interact with the Redux store in your components. It provides `useSelector` and `useDispatch` hooks, which are lighter-weight and generally easier to understand and work with than `connect` is. They're also much easier to use with TypeScript. The Redux docs have always been very unopinionated, and just said "here's 3 different ways to do this task" (such as describing the typical "folder-by-type" / "feature folder" / "ducks" folder structures, but not giving an actual suggestion on which approach to use). We now have a "Style Guide" docs page [2] that gives our actual recommendations on how to use Redux the right way, such as "put more logic in Reducers", "model actions as 'events' instead of 'setters' ", and "use the 'ducks' pattern for single-file logic". So, while the actual Redux core hasn't changed, the way you'd write your Redux code now would be significantly different than what you might have seen a couple years ago, and the new "Redux Essentials" tutorial linked in this HN thread is intended to teach these latest practices. [0] https://redux-toolkit.js.org https://redux-toolkit.js.org [1] https://react-redux.js.org/api/hooks https://react-redux.js.org/api/hooks [2] https://redux.js.org/style-guide/style-guide https://redux.js.org/style-guide/style-guide
- platz 6y agoImmer also is a huge improvement in combination with Redux
- weavie 6y agoWhat do people use instead of Redux these days?
- halfmatthalfcat 6y agouseReducer hook, MobX
- platz 6y agomy impression is, if you going choose a paradigm like MobX, you might as well use Angular, which is conceptually pretty similar, just with different opinions on library vs framework.
- acemarke 6y agoThat's the first time I've ever heard anyone say that "MobX and React are conceptually similar". MobX is technically based on an "observable" paradigm, but it's a completely different API and mental approach than RxJS is. Also, while MobX is commonly used with React, it's really a UI-agnostic state management library (same as Redux). I really wouldn't compare MobX and Angular at all. To me they look like completely different tools.
- nsonha 6y agono, you are making an argument that is React must be used a certain way (that is incompatible with MobX). I'm not sure what makes you think you're someone who can make gatekeeping statements like that if the react team never said such thing. MobX adds reactivity to your object oriented domain code and React allows you to write functional view component, what's wrong with that? And no using MobX and using Angular are 2 vastly different things. One can like MVVM (MobX) and dislike string template and other convoluted mechanisms Angular.
- nsonha 6y agoCrap library, even sourcing without process manager? (saga is an after thought) doco does not even bother to teach users about command/event distinction. The library works I guess, just like code i wrote in my junior years.
- valand 6y agoI understand the sentiment. Redux is quite misleading using the term events for command/action, which drives coder to use Redux's action as in-app events, tightly coupling Redux's synchronous store with asynchronous nature of events.