freeCodeCamp Challenge Guide: Map Dispatch to Props

Map Dispatch to Props


Solutions

Solution 1 (Click to Show/Hide)
const addMessage = (message) => {
  return {
    type: 'ADD',
    message: message
  }
};

// change code below this line
const mapDispatchToProps = (dispatch) => {
    return {
        submitNewMessage: (message)=>{
            dispatch(addMessage(message))
        }
    }
}
5 Likes