Tell us what’s happening:
I am having trouble understanding dispatch here. I thought in order to use dispatch, it had to be done like this: store.dispatch(action());
But in this lesson, we write it like this: dispatch(action())
. Please explain why, thank you.
Your code so far
const addMessage = (message) => {
return {
type: 'ADD',
message: message
}
};
// Change code below this line
const mapDispatchToProps = (dispatch) =>{
return {
submitNewMessage: (message)=>{
dispatch(addMessage(message))
}
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Challenge Information:
React and Redux - Map Dispatch to Props