Hello!
I reading the React book from Kirupa. And now I’m in section 15, about TodoList app. According to the book, Event onClick is used for the li element to remove list items:
createTasks(item) { return <li onClick={() => this.delete(item.key)} key={item.key}>{item.text}</li> }
Next in the book, the delete event handler is defined:
delete(key) { this.props.delete(key); }
Out of inexperience, I thought that there is extra code here I tried to do without the Delete handler. To do this, I specified the following code in the onClick handler of the li element:
createTasks(item) { return <li onClick={() => this.props.delete(item.key)} key={item.key}>{item.text}</li> }
And it works. Please tell me what problems there might be?