Skip to content
Discussion options

You must be logged in to vote

Yeah, Redux is by nature a global state solution.

It's worth noting though that if you're a particular fan of the slice pattern, it's possible to use reducers and action creators made with createSlice in combination with useReducer.

constcounterSlice=createSlice({name: "counter",initialState: {value: 0},reducers: {increment: (state)=>{state.value++;},},});const{ increment }=counterSlice.actions;functionComponent(){const[counterState,counterDispatch]=useReducer(counterSlice.reducer,counterSlice.getInitialState(),);return(<><p>Valueis{counterState.value}</p><buttononClick={()=>counterDispatch(incre…

Replies: 3 comments 9 replies

Comment options

You must be logged in to vote
5 replies
@EskiMojo14
Comment options

Answer selected byrazb-viola
@razb-viola
Comment options

@phryneas
Comment options

@EskiMojo14
Comment options

@razb-viola
Comment options

Comment options

You must be logged in to vote
1 reply
@EskiMojo14
Comment options

Comment options

You must be logged in to vote
3 replies
@markerikson
Comment options

@monochromer
Comment options

@EskiMojo14
Comment options

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
@razb-viola@markerikson@phryneas@monochromer@EskiMojo14