Send Action Data to the Store (Simplified EC6 not accepted or I am wrong?)

I know how to pass the test, by changing the addNoteText function to

addNoteText
const addNoteText (note) => {
  return {
    type: ADD_NOTE,
    text: note
  }
}

However, I wonder if my simplified code is still correct having the “return{}” omitted according to EC6 lesson write-arrow-functions-with-parameters/

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 action.text;
    // change code above this line
    default:
      return state;
  }
};

const addNoteText = (note) => {
  // change code below this line
  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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36.

Your solution is not accepted because is incorrect, with action creators you are supposed to return an Object.

Arrow function has an implicit return in function body.
For exmple:

const example = (n) => n+1

example(3) // 4

However in a block body the return statement must be explicit:

const example = (n) => { 
  n+1
}

example(3) // undefined

This means that Object literals require a slightly different syntax, they need to be enclosed in () parens

const func = () => { foo: 1 };
// still undefined


const func = () => ({ foo: 1 });
// Object {foo: 1}

Hope this helps :+1:

Thank you! You clear my cloud :smiley: