Organization And Storage Of Data
Can I keep my fortune in Redux? Should I always use a setState from React?
There is no “right” answer to this question. Some users prefer to store all the data in the Redux in order to maintain a fully serial and controlled version of their application over time. Others prefer to make non-critical (UI) data, such as “is this dropdown currently open” to the component.
Better use the component♪ That's it. Yours. Work, as a developer, decide which parts of the state are your annex and where each is stored. Find the balance that suits you and implement it.
Some non-public rules are described below to determine the parts of the data to be stored in the Redux repository:
- The other parts of the annex use these data?
- Will data based on these data be further developed?
- These data are used to manage several components?
- Is it important for you to recover this condition at some point in time, i.e. time travel debugging?
- Is it necessary to cash the data, i.e. to use what is already stored instead of re-request?
There are several packages that address different approaches Data storage in the Redux repository to the condition of the component, such as redux-ui, redux-component, redux-react-local and others. They also make it possible to apply the Redux principles and the educator ' s vision to update the locality of the component by supporting the idea of this.setState(previousState) = reducer(previousState), someAction).
Additional information
Articles
Discussions
Library
May I keep functions, promises or other non-serialized data in my repository?
It is strongly recommended that only simple serial objects, masses and primitives be stored in the vault. It may be technically possible to add non-serialized data in the storage facility, but this may impair the ability to preserve and reconstruct the storage facility, which will make it impossible to adjust on a time-travel debugging scale.