Redux toolkit docs doesn't cover the case or I didn't notice.
I have a reducer inside createSlice function:
reducers: {
addDigit: (state, action) => {
if (condition) {
}
}
}
Questions:
- I need to use pattern for redux toolkit and then get out of condition like
reducers: {
addDigit: (state, action) => {
if (condition) {
state.current = action.payload
return // <= I NEED RETURN HERE BECAUSE I HAVE ANOTHER CONDITIONS AFTER
}
}
}
or I need to use classic update pattern for redux (is it good for Immer?):
if (condition) {
return {
...state,
current: action.payload
}
}