This is the code generated by following the Redux course by Mosh Hamedani
- Design the store:
- What is the data store schema
- what information to keep
- Define the actions
- Functions that return an object with fields
type
andpayload
- Functions that return an object with fields
- Define the reducer
- A function in the form of
reducer(state, action) => updated_state
- A function in the form of
- Setup the store based on the reducer
- Create the store object and link the reducer
- Subscribe the UI elements to the store to get notified when the store is changed
- We can use
dispatch
function to invoke actions. - The invoked action will trigger the
reducer
function to get the updated state. - The UI elements that are subscribed will be updated based on the new state.