Send Action Data to the Store- Redux

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 ({
    // change code above this line
      return state;

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

const store = Redux.createStore(notesReducer);


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0.

Link to the challenge:

@nidhisharma Two things:


If you are using the return statement, breack is not required. This is more concise only with return.


No mutate the state. Principle of Redux. ¿What object must return you? ¿keys? ¿values of each keys?


Thanka a lot Yoelvis…

1 Like

@nidhisharma & @yoelvis,

You are right @yoelvis that a principle of Redux is not mutating state. Earlier in the Redux section, they explain that we are not worrying about making non-mutating changes to state yet. In this challenge state is not an object but a string. To make a change to this state without mutating we would use the concat() method. But the state is not initialized yet.

(state = 'Initial State', action)

This is a default value syntax that is used here. Because the state is not assigned any value anywhere else I think that the state will only be assigned this default value if the switch statement runs and a value is not assigned to it.

So I think that we are not mutating state in the exercise. But I am curious because it definitely felt like I was mutating state when I first completed this challenge.

Thank you for you explanation. This problem was making me increasingly frustrated, but tamed it by asking myself the questions you posted. Thanks :smiley:

1 Like