I am using React as my view. In different sections of the UI I need to show various properties from user object. Where should I store my user so that it'll be easier for me to architect the app?
P.S. I am not sure I'll use Flux or not. But I am open to suggestions!
Hi Nate!
TLDR
So I think you can go about this in a couple different ways.
One way is to just use localStorage to storage user information. This is simple and doesn't require you to change much in terms of the architecture of your application.
Another way is by either using Flux or Redux. I prefer to use Redux for my React applications. If you plan on getting more into React and building more applications using React then you will keep running into Flux or Redux.
Its important to note that Redux is an implementation of Flux and that Flux is an architecture that Facebook recommends when working with React or even just web applications in general.
More Info
Somasundaram Ayyappan
You can use contexts. Add your user object to
childContextTypesin your root App Component. Now you can get this object on any component down the tree.Without contexts, you have to pass down the user object as props to every component which requires it, which is not an elegant solution. Another solution is to get the user object from flux store, if you use any.
You can learn more about contexts here.
Note: Context is an experimental feature. It's API may change in future.