Tell us what’s happening:
The one thing I cannot seem to wrap my head around is where the function addMessage is being called. At what point does messageReducer get the addMessage function for an action?
Your code so far
// define ADD, addMessage(), messageReducer(), and store here:
// define ADD, addMessage(), messageReducer(), and store here:
const ADD = 'ADD';
const defaultState = {
messages: []
}
const addMessage = (mess) => {
return {type: ADD, message: mess}
}
const messageReducer = (state = defaultState.messages,action) => {
if(action.type == ADD){
let newState = state.concat(action.message);
return newState;
}
else{
return state;
}
}
const store = Redux.createStore(messageReducer)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
.
Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react-and-redux/extract-state-logic-to-redux