Send Action Data to the Store help

Send Action Data to the Store help
0

#1

Tell us what’s happening:
please tell me why me code isn’t working? when i click on runt tests, it just don’t run

Your code so far


const ADD_NOTE = 'ADD_NOTE';

const notesReducer = (state = 'Initial State', action) => {
  switch(action.type) {
    // change code below this line
     switch (action.type) {
       case ADD_NOTE:
         state = action.text;
         return state;
       default:
         return state;
         break;
        
     }
    // 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_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/redux/send-action-data-to-the-store


#2

you have two ‘default’ sections ,
one inside the switch
and one outside
remove the one inside and fix your brackets

ps. I think you need to be careful not to change state the way you are doing…(I think you should use setState)


#3

You have a switch nested in a switch. You only need to add a single case statement to the original switch statement. Reset the challenge and try again without creating a second nested switch statement.


#4

I m really sorry for my blunder. I will first check the code thoroughly then will ask question.