admin管理员组文章数量:1192330
I was wondering what is the difference between react events: onFocus
and onFocusCapture
. I could not find an appropriate answer on react's documentation page.
<OutlinedInput
label="price from"
onFocus={handlePriceFocus}
/>
<OutlinedInput
label="price to"
onFocusCapture={handlePriceFocus}
/>
In my case, it seems like onFocus
and onFocusCapture
do the same functionality because I have not noticed any difference when using those two events.
I was wondering what is the difference between react events: onFocus
and onFocusCapture
. I could not find an appropriate answer on react's documentation page.
<OutlinedInput
label="price from"
onFocus={handlePriceFocus}
/>
<OutlinedInput
label="price to"
onFocusCapture={handlePriceFocus}
/>
In my case, it seems like onFocus
and onFocusCapture
do the same functionality because I have not noticed any difference when using those two events.
1 Answer
Reset to default 27This is what React say in their documentation:
"The event handlers below are triggered by an event in the bubbling phase. To register an event handler for the capture phase, append Capture to the event name; for example, instead of using onClick, you would use onClickCapture to handle the click event in the capture phase." https://react.dev/learn/responding-to-events#capture-phase-events
So, I think there isn't anymore to say about that. What I understand it's like without 'capture' the code is executed after the event and with 'capture' it's executed before.
本文标签: javascriptReact onFocus and onFocusCapture differenceStack Overflow
版权声明:本文标题:javascript - React onFocus and onFocusCapture difference - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738417633a2085675.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论