Re:React Common Tools and Practices: State Management Overview
by phryneas on Monday March 08, 2021 @12:02PM
(#26388111)
That page introduces one tool after another, replacing all those external tools with the officially recommended Redux Toolkit that wires all of them up for you.
In the end you are left with only
`import { configureStore, createSlice } from '@reduxjs/toolkit'`
Re:React Common Tools and Practices: State Management Overview
by dmitriid on Monday March 08, 2021 @12:41PM
(#26388787)
> That page introduces one tool after another, replacing all those external tools with the officially recommended Redux Toolkit
Perhaps. As person who's never used thunks or, really, half of those tools in conjunction with Redux, this tutorial is quite confusing.
> In the end you are left with only import { configureStore, createSlice } from '@reduxjs/toolkit'
The final code on the page is literally
import {
createSlice,
createSelector,
createAsyncThunk,
createEntityAdapter
} from '@reduxjs/toolkit'
The page doesn't really address the issue of verbosity and the flow as described in the original comment. It just hides some of it behind some facades with autogenerated accessor functions (so, even more levels of abstractions).
Re:React Common Tools and Practices: State Management Overview
by acemarke on Monday March 08, 2021 @12:48PM
(#26388926)
Yes, the entire point of that page is:
- You've gone through this whole tutorial sequence and should now understand how to write all this Redux logic "by hand" and why these standard Redux usage patterns exist
- Now, here's how Redux Toolkit abstracts and simplifies those exact same patterns, so that you can do the same thing with less code, but you understand what those abstractions are doing for you internally.
--- start quote ---
import { combineReducers } from 'redux'
import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
const composedEnhancer = composeWithDevTools(applyMiddleware(thunkMiddleware))
import { createSlice } from '@reduxjs/toolkit'
...createSlice will automatically generate action creators
--- end quote ---
It's.... it's not better in any way?
> Redux goes the "signalling" way, MobX goes the "observing" way, both have their benefits and drawbacks.
I like Svelte's approach. Where they figure out which things are being observed or changed at compilation/transpilation time and generate code for that case specifically.