Based on an example in page: https://redux.js.org/basics/usage-with-react
We have the following item:
const Todo = ({ onClick, completed, text }) => (
<li
onClick={onClick}
style={{
textDecoration: completed ? 'line-through' : 'none'
}}
>
{text}
</li>
)
Todo.propTypes = {
onClick: PropTypes.func.isRequired,
completed: PropTypes.bool.isRequired,
text: PropTypes.string.isRequired
}
Also, we have the:
const TodoList = ({ todos, onTodoClick }) => (
<ul>
{todos.map((todo, index) => (
<Todo key={index} {...todo} onClick={() => onTodoClick(index)} />
))}
</ul>
)
Can someone please tell me what is the {...todo} on the above code?
I know that the ... operator is a spread syntax and is used lets say as [...todos, newTodoItem] (to concatenate new todo item to the old todos list). But, in the example above, todo item is not an array and it seems like it generates an object. As such for me it looks like {...todo} is equal to {todo}.
Also, what kind of properties are getting assigned on the component?