A starter for simple React projects based on the state reducer pattern.
This is a starter package for bootstrapping a react project.
It is based on create-react-app and also includes:
For state managament, it has the barebones of a state management approach based on a the State Reducer pattern:
App is loaded with two props:
initialState
- Application level state object.stateReducer
- A reducer function that is provided the current state and an updater
object (akin to a redux action) and that based on this can update the state object.App
is equipped with a setInternalState
function to be called in place of setState
and which takes an updater
object or function and a callback. setInternalState
calls setState
, but before it does so it generates a set of changes by passing the updater through this.props.stateReducer
.
The initialState
and stateReducer
are defined in a file state.js
. Updater functions can be placed in a file updater.js
.
Note that the stateReducer
must always return the original state by default when no change is in order.