3 ms·
What do you do with state that needs to be global, or state that bits of start needing to be available in many components for example current username or permis
by andy_ppp 6y ago
What do you do with state that needs to be global, or state that bits of start needing to be available in many components for example current username or permissions etc?
- shermanmccoy 6y agoThis is not a religious stand against all global state. Username, permissions fine to be global, this is very easy for someone new to your code to grok. I put them in the top React context, then just useReducer where I need to. Don't need to pass down through props to every component anymore, thanks to React context and useReducer. Although I was thinking if you wanted to be a religious zealot about not coding any of your own global state you could use the browser session API.
- Cthulhu_ 6y agoReact Context is the use case for that one.