score:8

Accepted answer

this is the syntax for parameter object destructuring, which was introduced as part of ecmascript 2015. the todos function doesn't define a single parameter named todos, but instead accesses the todos property of an object that's passed in (and that is immediately destructured).

it is roughly equivalent to the following version:

const todos = (_param) => {
  let todos = _param.todos;
  return (
    <div>
      <h1>todos</h1>
      {todos.map(todo => <p key={todo}>{todo}</p>)}
    </div>
  );
};

check out destructuring and parameter handling for more information on destructuring.


Related Query

More Query from same tag