3 ms·
I think the largest myth that exists in the react world is the need to have a global state for everything. I've seen too many failures when teams go from displa
by rhacker 7y ago
I think the largest myth that exists in the react world is the need to have a global state for everything. I've seen too many failures when teams go from displaying "this one thing" to suddenly have the requirements to display two or more of that at the same time. Redux global state for the user that is logged in? that's OK, but do you really need Redux for that?
Our team uses hooks and context for everything, and a little bit of legacy redux usage.
- acemarke 7y agoFWIW, we have some rules of thumb in the Redux docs for when it _might_ make sense to put data in the Redux store: https://redux.js.org/faq/organizing-state#do-i-have-to-put-all-my-state-into-redux-should-i-ever-use-reacts-setstate https://redux.js.org/faq/organizing-state#do-i-have-to-put-a... We're currently working on a major rewrite of the Redux core docs, and will emphasize this thought process in more areas of the docs as we go.
- Supermancho 7y ago> I think the largest myth that exists in the react world is the need to have a global state for everything. Client state management is all global no matter the strategy. ie Component level stores are effectively namespacing a global space with more cruft. When you get into sets of components, the convenient store gets ugly/brittle no matter how you do it, so might as well keep it in a single store.
- veeralpatel979 7y agoHey! Author here. You don't need to put the username of the logged in user into Redux, but if multiple components across different pages need to access this data, you should make it globally accessible. You can choose Redux/MobX for this, or you can roll your own solution with context and hooks. I'm actually learning more about the context/hooks approach myself. Kent C Dodd wrote a great article on this topic I'd recommend: https://kentcdodds.com/blog/application-state-management-with-react/ https://kentcdodds.com/blog/application-state-management-wit...