jjzjj

deletePerson

全部标签

javascript - 在 React 中,为什么我必须绑定(bind)一个 onClick 函数而不是调用它?

在thistutorial他使用带有绑定(bind)的onClick函数。当我像这样移除绑定(bind)时我得到一个错误UncaughtError:InvariantViolation:setState(...):Cannotupdateduringanexistingstatetransition(suchaswithinrender).Rendermethodsshouldbeapurefunctionofpropsandstate.我知道bind的作用,但为什么这里需要它?onClick不是直接调用函数吗?(代码在这个JSbin中:https://jsbin.com/gutiwu