Extract State Logic to Redux - 7/19

Extract State Logic to Redux - 7/19
0

Tell us what’s happening:
I don’t see any error in js, the test results are Cannot read property 'type' of undefined for all the cases. What am I missing?

Your code so far


// define ADD, addMessage(), messageReducer(), and store here:
const ADD = 'ADD';

const addMessage = (message) => {
  return {
    type: ADD,
    message: message
  }
}

const defaultState = [];

const messageReducer = (state = defaultState, action) => {
  switch(action.type){
    case ADD:
      return [...state, action.message];
      break;
    default:
      return state;
  }
}

const store = Redux.createStore(messageReducer());

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react-and-redux/extract-state-logic-to-redux

Nevermind, the issue looks like I only have to pass the function when creating the redux store, removing the () helped.

const store = Redux.createStore(messageReducer());

shouldnt messageReducer have addMessage for action, otherwise youre trying to find the type of undefined?