Yup, redux will mess with your head when you first learn it. Yup. But once you get it, it’s a great tool.
Some thoughts:
return {
state: addNoteText(text)
};
What is state? In this reducer, according to the setting of initial state, it is a string. But here you are returning an object. State is a string so you should return a string. (It’s a little odd to set the initial state to the string 'Initial State', but that was what was given to you, so don’t worry about it.) The instructions tell you:
…it should return the text property on the incoming action as the new state. So, first of all, it should be a property of the action variable you are getting, and it shouldn’t be wrapped in an object. Where is this text data? Notice that what you return from the action creator:
return {
type: ADD_NOTE,
text: note
}
That is what goes into the reducer as the variable action. You can see where the property type is used. Now do something similar to get the text data that you want.
When I make those changes, it passes.
Don’t get frustrated. This is hard. A year and a half ago I was struggling with Redux too. Now I do it for a living. YMMV. Just keep at it - it’s frustrating but worth it.
I should mention, I tried {state: action.text} as well
That’s closer. It’s the right data, but it’s wrapped in an object. You aren’t supposed to return an object that contains state, but should return state itself.
Ooooooooo gees. Perfect. that makes so much more sense. For some reason, with Redux, it feels like its hard to see the forest for the trees! Thank you for the help!
Yes, Redux is bat crap crazy and makes no sense. Until it makes sense and then it is awesome. But yeah, what you’re feeling right now is completely normal.