This is a starter package for bootstrapping a react project.
It is based on create-react-app and also includes:
- react-testing-library
- lodash
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 anupdaterobject (akin to a redux action) and that based on this can update the state object.
-
Appis equipped with asetInternalStatefunction to be called in place ofsetStateand which takes anupdaterobject or function and a callback.setInternalStatecallssetState, but before it does so it generates a set of changes by passing the updater throughthis.props.stateReducer. -
The
initialStateandstateReducerare defined in a filestate.js. Updater functions can be placed in a fileupdater.js. -
Note that the
stateReducermust always return the original state by default when no change is in order.