I am building a dashboard for my site in ReactJs using the flux architecture.
Now let's say I have a UsersComponent which displays a list of all users registered in the website, and this component has a UsersStore where the data is fetched and stored.
Inside UsersComponent I render a sub component named UsersStatsComponent which is a small widget that displays statistics from the last 24 hours (number of new registrations, blocked users and more...) these statistics comes from a different API endpoint.
Where should I manage the data for this sub component?
I consider my options are:
- Create another store named UsersStatsStore which fetches the data from the API and emits the change event to UsersStatsComponent.
- Use the same store of UsersStore and create another action inside this store and emit a different event when the data has fetched from the API.
What is the best practice for this?