Best practice for Typescript + Slice Pattern + Immer + Devtools #2070
-
Hello everyone, I've set up a structure as follows. In this structure, I'm using both the slice pattern and immer + devtools middleware. Is this the best practice for this situation, or do you know of a better solution? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
@utkubiz looks good to me. I would do the same. You are on the right path. +1 for |
Beta Was this translation helpful? Give feedback.
-
Great! This was exactly what I was looking for. Thank you! |
Beta Was this translation helpful? Give feedback.
-
nice, looks good! the only thing i cannot understand is how applying devtools on the resulting store is getting into autocomplete of related props on the slice level... how does TS know that there can be a third argument for set function? export const practiceSlice: ImmerStateCreator<PracticeState> = (set) => ({
activeQuestion: 0,
nextQuestion: () =>
set(
(state) => {
state.practice.activeQuestion++;
},
undefined,
{ type: "nextQuestion" },
),
}); Is it coming from |
Beta Was this translation helpful? Give feedback.
@utkubiz looks good to me. I would do the same. You are on the right path. +1 for
ImmerStateCreator