Hi Brendan! In production at work, we have actually moved dispatch into its own context and have a useDispatch and useStore hook. Usually, components needed to dispatch actions don't generally need to use the state itself. This will probably cut down on a lot of the re-renders you're seeing.
Another option for possibly reducing the amount of calls would be to create a "hydrate store" action that does all the initial loading of state you need in one action. I'm not sure how feasible this is in your project, but its something we're doing as well.
Ramsay, loved your Article. I actually was able to follow it and implement it on something that I have been working on. Wondering you how you would have created the useDispatch and the "hydrate store" action?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Brendan! In production at work, we have actually moved dispatch into its own context and have a
useDispatch
anduseStore
hook. Usually, components needed to dispatch actions don't generally need to use the state itself. This will probably cut down on a lot of the re-renders you're seeing.Another option for possibly reducing the amount of calls would be to create a "hydrate store" action that does all the initial loading of state you need in one action. I'm not sure how feasible this is in your project, but its something we're doing as well.
Thanks for the reply! This definitely gives me something to chew on
Ramsay, loved your Article. I actually was able to follow it and implement it on something that I have been working on. Wondering you how you would have created the
useDispatch
and the "hydrate store" action?