13

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 1

17

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.