My code below gives me the error similar to this question:
"Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state."
class BookList extends React.Component
{
removeBook(bookName)
{
Actions.UpdateBooks();
}
render()
{
return (
<TextField defaultValue={this.book.name} />
<i onClick={this.removeBook(this.book.name)} />
);
}
}
Makes sense - the function is called every time render occurs.
So I changed the binding to
onClick={function() {this.removeBook(book.name);}
and now the method is never called when I click. Why?