How can I add an arrow function to the onClick property of the props?
- 内容介绍
- 文章标签
- 相关推荐
本文共计150个文字,预计阅读时间需要1分钟。
在示例中,它甚至警告了将 `OnClick` 设置为 `{}` 的问题,因为这会导致该函数在每次渲染时被调用。这只是一个简单的封装,以防止这种低效的行为。
EarlierintheexampleitevenwarnsaboutsettingonClick={}asitwillcallthatfunctEarlier in the example it even warns about setting OnClick={} as it will call that function on every render call.This simply wraps it to prevent that inefficiency and only call the function on click.
该提问来源于开源项目:reactjs/reactjs.org
Nevermind, I've started learning React and I now understand what's going on here, and how the injected JSX gets called when a render happens.
本文共计150个文字,预计阅读时间需要1分钟。
在示例中,它甚至警告了将 `OnClick` 设置为 `{}` 的问题,因为这会导致该函数在每次渲染时被调用。这只是一个简单的封装,以防止这种低效的行为。
EarlierintheexampleitevenwarnsaboutsettingonClick={}asitwillcallthatfunctEarlier in the example it even warns about setting OnClick={} as it will call that function on every render call.This simply wraps it to prevent that inefficiency and only call the function on click.
该提问来源于开源项目:reactjs/reactjs.org
Nevermind, I've started learning React and I now understand what's going on here, and how the injected JSX gets called when a render happens.

