Now let’s add some starter code for the redux store.
Install the redux
, react-redux
and redux-thunk
libraries.
In the src/external/redux/constants.js
file create three constants ADD_LIST
, LISTS
, WORDS
.
The meaning of each constant must be the same as its name.
In the src/external/redux/actions.js
file, you need to create and export the action creator addList
This function must return an object with two fields: type
and payload
.
The type
field must be the ADD_LIST
and payload
must be the action creator argument.
In the same file, add the addListResult
method, which will be the first argument to receive the state of the application, and the second - payload from the addList
action.
This method should return an updated state. Only the LISTS
property should be updated.
The addListResult
must add a new object with the key
field equal to the second argument of addListResult
.
The second field of this object must be createAt
, equal to the result of calling moment
.
Use this method for the reducer
in the src/external/reducer/store
file for the ADD_LIST
case.
The default storage should have 4 properties - LISTS
and WORDS
- empty arrays, loading
- false
, error
- null
.
From the src/external/reducer/store
file, do not forget to export by default the creation of a store with the connected middleware thunk
.
This task is part of the Full-Stack JavaScript Course.
If you have any issues with it, you can ask for community help below the post.
Feel free to help others if you’ve already solved the task.