Extract State Logic to Redux - messageReducer should be a function

Tell us what’s happening:

Getting errors in console window as given below:
messageReducer should be a function.

store is not defined

store is not defined

store is not defined

Your code so far


const ADD = 'ADD';

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

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

   }
 };

 const store = Redux.createStore(messageReducer); 
 store.dispatch(addMessage('abc'));
}

Your browser information:

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

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

1 Like