stopImmediatePropagation is not available for synthetic events
See original GitHub issueIn order to call this method, you’d have to access it via event.nativeEvent.stopImmediatePropagation()
: https://developer.mozilla.org/en-US/docs/Web/API/Event/stopImmediatePropagation
It’d be awesome if this was supported on event
itself. I did see a prior issue for this, but it was for a use case that sIP wasn’t required for.
For a specific use case: if you want to kill hover events for touch input, onTouchStart
will trigger onMouseOver
and stopImmediatePropagation
cancels that internal cascade.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:20
- Comments:15 (2 by maintainers)
Top Results From Across the Web
ReactJS SyntheticEvent stopPropagation() only works with ...
React Stop Propagation on jQuery Event. Use Event.stopImmediatePropagation to prevent your other (jQuery in this case) listeners on the root from being called....
Read more >Event.stopImmediatePropagation() - Web APIs | MDN
The stopImmediatePropagation() method of the Event interface prevents other listeners of the same event from being called.
Read more >SyntheticEvent - React
This reference guide documents the SyntheticEvent wrapper that forms part of React's Event System. See the Handling Events guide to learn more.
Read more >Why isn't event.stopPropagation() working?!
Instead you can use event.nativeEvent.stopImmediatePropagation() to stop event propagation and prevent events being bubbled to parent component.
Read more >StopPropagation vs. StopImmediatePropagation in JavaScript
In the JavaScript event system, there are two event phases — bubbling and capturing. Image source: W3C. Not every DOM event is supportive...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I concur with the above. The documentation for SyntheticEvent states:
Not having
stopImmediatePropagation
on it violates the promise that the interface is the same.If this won’t be fixed, at least fix the docs to stop claiming that the interface is the same when it’s not.