How can I add an arrow function to the onClick prop?
- 内容介绍
- 文章标签
- 相关推荐
本文共计135个文字,预计阅读时间需要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.
本文共计135个文字,预计阅读时间需要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.

