Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React onFocus and onFocusCapture difference

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.

like image 205
Ismoil Shokirov Avatar asked Mar 25 '21 11:03

Ismoil Shokirov


1 Answers

This 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." reactjs.org/docs/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.

like image 115
Ezequiel Guitler Avatar answered Oct 19 '22 18:10

Ezequiel Guitler