Good day. I am writing a SPA application on react + redux, in principle, the flux approach is understandable, but some things cause questions. For example, I brought to the global store data about an authorized user, because they are used in many modules for access sharing, etc. there are no questions here.
But how to deal with the data of the pages themselves, for example, I have a page with statistics, is it wise to take this data to the global side (create actions, reducers), because after switching to another section they will not be needed, but they will hang in memory. Why not to store all data on page in local state?
Actually the question is when and what data really needs to be taken out in the global store?
storewhen data is needed in several components. Say, the user store there is a really good idea. If data is present in only one component, store it in the local state. Another useful feature of the store is to pull up a large array of data before they are needed. Say, there is data only in one component, but they need to be updated regularly, and generally they pull slowly from the server - it will be reasonable to put them on right after the user's authorization (logged in, hit the dashboard \ index page, pull the data). - Klimenkomud