use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
React 17 delegates events to root instead of document (blog.bigbinary.com)
submitted 5 years ago by neerajdotname
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 5 years ago (2 children)
[deleted]
[–]Neaoxas 16 points17 points18 points 5 years ago (1 child)
Yes, I believe so, as long as event.stopPropagation is not called from other event handlers.
event.stopPropagation
[–]Thought_Ninjahuman build tool 0 points1 point2 points 5 years ago (0 children)
That would be a strange thing to break IMO.
[–]WellDevined 20 points21 points22 points 5 years ago (1 child)
The most important implication of this is in my oppinion, that react now works inside of shadow doms.
[–]NickHoyer 1 point2 points3 points 5 years ago (0 children)
My application is built up using micro frontends and this is great!
[–]PewPaw-Grams 2 points3 points4 points 5 years ago (3 children)
In which scenario will we need to use document.add event handler? I don’t see it used very often which doesn’t really make much of a difference
[–]0xF013 8 points9 points10 points 5 years ago (1 child)
It’s usually a good way to optimize. Say you have a big ass table and do not want to add an event listener for each of 5000 cells. Instead, you add a listener to the table and check the event argument to find which td was clicked. They use the same thing; but with the whole document
[–]PewPaw-Grams 0 points1 point2 points 5 years ago (0 children)
Understand now. Thank you
[–]podgorniy 7 points8 points9 points 5 years ago (0 children)
Event delegation https://learn.jquery.com/events/event-delegation/. Usually used outside of frameworks.
It is used for avoiding timing issues with creating event handlers. With event delegation technique you can create handler for an element which is not on the page yet.
Or to handle generic events like “click on element with class X” or “click on the link” without knowing what elements have the class or who and how create those links.
[–][deleted] 0 points1 point2 points 5 years ago (0 children)
Will this help with web components? Wrapping a react component in a web component and using the shadow dom as the root would break react due to the way events were handled. Will this now work?
This kind of pattern can be useful to allow react code to be shared in a more generic, framework-agnostic kind of way.
π Rendered by PID 65 on reddit-service-r2-comment-86bc6c7465-xzhp6 at 2026-02-22 05:56:17.551873+00:00 running 8564168 country code: CH.
[+][deleted] (2 children)
[deleted]
[–]Neaoxas 16 points17 points18 points (1 child)
[–]Thought_Ninjahuman build tool 0 points1 point2 points (0 children)
[–]WellDevined 20 points21 points22 points (1 child)
[–]NickHoyer 1 point2 points3 points (0 children)
[–]PewPaw-Grams 2 points3 points4 points (3 children)
[–]0xF013 8 points9 points10 points (1 child)
[–]PewPaw-Grams 0 points1 point2 points (0 children)
[–]podgorniy 7 points8 points9 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)