I'm going to start a new React project and try to use my previous knowledge to create some rules about how I structure the application.
Some things that I think are true:
- Redux contains the "core" data for the entire application.
- Redux can contain the state of the user interface if it should be common for the application (for example, global modal windows that can be launched from anywhere).
- Components may contain their own state c
setState, if this state does not need to be distributed elsewhere in the application. - If necessary, use stateless components
- When I create a component that needs state from Redux, I will create the files
FooContainer.jsand FooComponent.js- the Redux connection code will be in the container.
There are large parts of the application that are heavy UIs and have a lot of UI logic / state, but do not need any state from Redux.
I feel that with the liberal use of state at the component level I have to use more container components to build smaller, unparalleled components. However, I see many container component definitions as "HOC that connects to Redux"
, Redux , , Redux, ?
, - , .., ?