Any performance concerns with creating nested reducers? #2109
-
Hello! My apologies if this has recently been answered elsewhere, but most threads I found on this topic were prior to the release of the React hooks API, so figured a fresh question wouldn't hurt. Note: unfortunately the code I am working with for this question is large enough and old enough that converting to Redux Toolkit is not an option. So this question assumes the older actions/reducer pattern I have a code library (call it
The number of reducers both within
Assuming my selector functions already target the most specific piece of state applicable to a given component, are there any performance impacts I should be aware of if I moved to this structure? It seems like state updates could become more expensive (if, for example, I wanted to set myLibrary.state1.attribute1), but I'm not certain. The reducers within myLibrary are completely disconnected from each other, the only thing they have in common is being defined within Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, no meaningful perf considerations here - just keep selecting the most specific state possible in components. As a side note, you can migrate existing code to RTK incrementally, file-by-file, and we strongly recommend at least switching the store setup to RTK's |
Beta Was this translation helpful? Give feedback.
No, no meaningful perf considerations here - just keep selecting the most specific state possible in components.
As a side note, you can migrate existing code to RTK incrementally, file-by-file, and we strongly recommend at least switching the store setup to RTK's
configureStore
to get the dev mode checks active in your codebase: