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
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 (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: