Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
July 13, 2021 11:57 am GMT

How to architecture state variables in React.

Hello Devs, in this article, we will see how to architecture the state variables in your react app.

  • If a state is used by a single component it should be inside that component.

  • If a state is used by multiple components in a tree and they are all direct children of the same parent component, it should be in their parent component.

  • If a state is used by multiple components in a tree but they are not direct children of the same parent component, it should be in context/redux.

  • If a state is used by multiple components in different trees, it should be in context/redux.

Thank you, for reading this far. I hope this article helped you.

Happy coding.


Original Link: https://dev.to/saran_chakravarthi/how-to-architecture-state-variables-in-react-42h2

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To