So, I'm sitting down to create ReactJS components that visualize a page with data and actions (using Redux), but there are a lot of moving parts! What is a good sequence of steps when constructing using React and Redux? It's pretty confusing at this point where to start, and I can't seem to build up code that runs at each step. It seems I have to construct the whole enchilada at once.
First attempt at creating a recipe for constructing React + Redux with components/containers/actions/states:
- Construct Components first and their hierarchy displaying with dummy data
- define a dummy data that will become props later
- define dummy functions or handlers that will become actions later
- display page with dummy page and components
(the rest of these steps will break compile until all completed...)
Define propTypes and getInitialState for each component
- this will break components
- map props to data and functions (for actions later)
Create wrapper container for root components
- not done for all components
- this is still a broken compile state until all pieces added
Create actions next
- still don't have the exact state 'structure' defined this comes next in reducers...
- action sort-of perform CRUD on my basic data that is really returned in reducers
Create reducers
- take a stab as some ADD or SET action to create initial state data
- this is using the dummy data defined above
- create one reducer per one state 'data'
Update both action and reducers as needed until state.myData looks good
Assemble connect() with reducers...
- create connect(mapStateToProps, mapDispatchToProps)(wrappedComponent)
- define mapStateToProps - define JSON for data returned using some state.someData and state.someOtherData
- define mapDispatchToProps - add action(s) as prop function
Now, include reducers into store at top-level
- let store = createStore(myCombinedReducers)
Revisit initial components and check
- props are covered for incoming data (store state) and functions (really actions)
Revisit wrapper containers
- check mapStateToProps has returning right "data" name
- note: state data can be used at the component, or here at the mapStateToProps, so it not always obvious at first
- may need to add additional transform based on filtering,etc
- check mapDispatchToProps has proper action to function handlers
More checks, looking at mapStateToProps and mapDispatchToProps
- perform search 'state.someData' using Find on Files and check used correctly in all the right places
- perform search 'functionHandler' using Find on Files and check used in right places
Well, is there a better approach?
Thank you ahead of time!