-
I was thinking to write a selector containing all the actions of the store:
As the actions never gets updated, is writing a selector for each action useless in term of performance? |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Feb 22, 2021
Replies: 1 comment
-
I'd say it's a subtle difference and you can do either way. More performant way is: const actions = {
setValue: useStore.getState().setValue,
setComponents: useStore.getState().setComponents,
setEditor: useStore.getState().setEditor,
setPlugins: useStore.getState().setPlugins,
}; Or, not defining actions in the store in the first place. But, again it would be a subtle difference and you wouldn't notice unless benchmarking in artificial settings. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
zbeyens
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd say it's a subtle difference and you can do either way.
If you are keen about the performance, it's still creating an object and shallow compare it in every render.
More performant way is:
Or, not defining actions in the store in the first place. But, again it would be a subtle difference and you wouldn't notice unless benchmarking in artificial settings.