DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Discussion on: How I structure my React projects

Collapse
 
dotorimook profile image
dotorimook

Thanks for sharing!
Could you explain the difference between stores and providers and the reason why providers is in utils folder and stores in root separately?

Collapse
 
larswaechter profile image
Lars WΓ€chter Author • Edited on

stores are global states across the whole application managed by zustand, which is a state-management library.

providers are actually React Context providers. I use them mostly to make the state management for "large" pages with a deep component tree easier. I guess you could also put them into the directory of the according "page" component.

So stores are accessible from anywhere within the application while providers are mostly used for some specific pages.

Collapse
 
dotorimook profile image
dotorimook

Thank you! Your explanation was very helpful to understand!