I am currently stuck trying to understand this bit of ReactJS code from here:
const TodoList = ({ todos, onTodoClick }) => (
<ul>
{todos.map(todo => (
<Todo key={todo.id} {...todo} onClick={() => onTodoClick(todo.id)} />
))}
</ul>
);
I believe that ({ todos, onTodoClick }) => (...)
is called a destructuring bind? But from the examples I've seen of them follow this pattern: {...} => (...)
, as in the initial hash is not surrounded with parentheses, contrasting my example.
Edit: examples of this are here and here.
What I also don't understand about it is that it seems like this is a function that updates a value and yet it is declared with const?
I looked around this site for a bit, and I found explanations of destructuring binds, but none of them seemed to give me insight into understanding this code.
Thank you very much for taking the time to read this question.