Send Action Data to the Store, Not updating the store value

Tell us what’s happening:

Your code so far


const ADD_NOTE = 'ADD_NOTE';

const notesReducer = (state = 'Initial State', action) => {
  switch(action.type) {
    // change code below this line
    case ADD_NOTE: return ({
    text: action.text
    });
    // change code above this line
    default:
      return state;
  }
};

const addNoteText = (note) => {
  // change code below this line
  return ({
    type: ADD_NOTE,
    text: note
  });
  // change code above this line
};

const store = Redux.createStore(notesReducer);

console.log(store.getState());
store.dispatch(addNoteText('Hello!'));
console.log(store.getState());

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Couple things are wrong with your code.

Make sure you are returning an object from the action creator. Therefore, surrounding your returns with () is not necessary.

case ADD_NOTE: return ({
    text: action.text
    });

Next, your reducer just wants to return note that was passed in through by the action creator. Instead of reassigning the action to the text in an object, simply return the text you received.
Also you need to “break” out of your case after returning.