- Less boilerplate (no actions, for example)
- Declare a state container using a HOC
- Easily add 'reducers', which become methods to the state object
- Built-in update and reset functions
- Add auto-calculated fields (like 'canNavigateToCompositionSection')
- Easy persistence (sessionState)
- Per-route persistance
screen's index.js's compose
withStateContainer(
default: { // or, (props) =>
name: null,
panel: 'metadata',
compositionRights: {
}
},
reducers: {
changePanel: (newPanel) => ({
panel: newPanel
})
},
calculated: {
isValid: (state) => !!state.name
}
)
Then in template.js
Layers:
- state values
- computed values
- reducers
- utility functions (don't change state)
Ramblings:
- should it be possible to add reducers further down in the component tree?
- use context to pass down value