Send Action Data to the Store - update state fails

Tell us what’s happening:

Getting this message on submit. Difficult to interpret but seems to say i’m not updating the state? I’m creating a new copy of the state object, assigning the note text and returning it. I’ve looked at other people’s solutions but they jus seem to be returning a string, not bothering with the state. I don’t understand what’s wrong. Heres the message:

Dispatching an action of type ADD_NOTE with the addNoteText action creator should update the state to the string passed to the action creator.

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 Object.assign({},state, {
        text: action.text
    // change code above this line
      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);


Your browser information:

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

Link to the challenge:

1 Like

In your reducer, you need to return a string when the ADD_NOTE case is triggered, not an object.


hi joops,
thanks for responding. I know that works to pass the challenge, but I thought I was supposed to return a copy of the state object in the reducer. in previous challenges returning a changed copy of the state object worked. In the basic example from redux, it shows returning an object

It sounds like in those other challenges the state was a object, in which case returning a new object is the correct thing to do. However, in this example, the state is a string. This is evident from the default state which is declared in the reducer:

state = 'Initial State'

Therefore, a new string must be returned from the reducer.


ahhh, clarity! thanks very much Joops. yep, I totally didn’t see that.

1 Like