by taooftea · 6y ago · 0 comments
I only worked on documentation and presentation.
Personally I don't like the design pattern, a matter of taste. But it's very annoying now in the market to have mixed React and Hooks codebases, with all their issues..
https://reactjs.org/docs/hooks-faq.html#what-is-the-prior-ar...
Our official Redux Toolkit package [0], which is now our recommended approach for writing Redux logic, _does_ have a few more deps: Immer, Reselect, Redux-Thunk, and the Redux core. But, those are all things you probably would have had in your app anyway.
If you're not familiar with Redux Toolkit, 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.
I just published a brand-new "Redux Essentials" core docs tutorial [1], which teaches beginners "how to use Redux, the right way", using our latest recommended tools and practices. I'd encourage folks to check it out.
[0] https://redux-toolkit.js.org
[1] https://redux.js.org/tutorials/essentials/part-1-overview-co...
I'm too out-of-the-loop these days to know what Immer is, will have to give it a look.
Quick summary:
Immer is an incredibly useful immutable update library, created by Michel Weststrate (author of MobX).
It exports a single function `produce(originalState, updateCallback)`. The callback receives a `draftState` value that _looks_ like your original state, but has been wrapped in an ES6 Proxy. You can then "mutate" the draft all you want. Internally, Immer tracks all the mutations, and the final result is a safely immutably-updated value.
It drastically simplifies immutable update logic - no more nested spread operators!
See https://immerjs.github.io/immer/docs/introduction and https://redux.js.org/recipes/structuring-reducers/immutable-... .
Redux Toolkit comes with Immer built into our `createReducer` and `createSlice` APIs automatically.
Gasp! Will redux store no longer be an observable then?