1.0.5 • Published 4 years ago
redux-store-codegen v1.0.5
Code Generator for Redux
Prerequsites
npm install -g redux-store-codegen
npm install redux react-redux redux-thunk
Instructions
- cd into the directory you want to create the store in
- create store.schema.json file in the directory, each root level key represents a module, eg.
{
"auth": {
"user": {
"value": {},
"isAsync": true,
"asyncVerb": "fetch"
},
"access_token": null,
"refresh_token": null
},
"posts": {
"posts": {
"value": [],
"isAsync": true,
"asyncVerb": "fetch"
}
},
"comments": {
"comments": null,
"likeCount": null
}
}
Note: If isAsync flag is provided, _BEGIN, _SUCCESS, _FAIL action types will automatically be created along with relevant state flags
- run script, passing in schema as first parameter
create-redux-store ./store.schema.json
- /store directory will be auto generated, enjoy!
Note: import your newly created store from /store/store.js in App.js component and wrap with provider as per redux installation guide: https://react-redux.js.org/introduction/quick-start#provider
Generated Store Example
Action Types
Action Creators
Reducers
Selectors