The AddingListOrWord
container must be connected to the store using the connect
method.
We will use both mapStateToProps
and mapDispatchToProps
.
mapStateToProps
must return two loading
and error
properties from the state.
mapDispatchToProps
must return an object with three properties: dispatchAddList
, dispatchFetchWord
, dispatchClearError
.
Their values ββare addList
, fetchWord
and setError
respectively.
When clicking on the Add
button, the value of the input field should be cleared.
When clicking the Add
button for the ADD_WORD_SCREEN
screen, the dispatchFetchWord
method should be called.
In this case, its first argument must be the value of the input field before clearing, with spaces removed at the edges in lower case.
Remember to pass the second and third arguments: route.params.listKey
and navigation
.
When you click the Add
button for the ADD_LIST_SCREEN
screen, call the dispatchAddList
method.
In this case, its only argument should be the value of the input field before clearing, with spaces removed at the edges.
When entering text into a field, the dispatchClearError
method must be called with a null
argument.
That said, everything else should work as before.
Also, this method with the same value should be called when the back button is pressed (cancel icon).
After cleaning up, call the navigation.goBack()
method.
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.