3

In this Discuss thread, Sophie Alpert says this about event handling in React:

We don't guarantee anything about event ordering between React events and native events.

However, I'm curious if it's safe to assume that React "capture" events, such as onClickCapture will always trigger before any native non-capture events.

For example, can I assume that a click on the React-rendered div in MyComponent will always log "Clicked the div" before it logs "Clicked the window"?

window.document.addEventListener('click', () => {
  console.log('Clicked the window');
}

const MyComponent = () => (
  <div onClickCapture={() => console.log('Clicked the div')}>
    A Div
  </div>
);
Jordan Eldredge
  • 1,587
  • 1
  • 19
  • 25
  • I just found this comment which seems to indicate that the answer is "no": https://stackoverflow.com/questions/34522931/example-for-bubbling-and-capturing-in-react-js#comment75059987_34523743 – Jordan Eldredge Aug 06 '17 at 22:14

0 Answers0