reactjs - React - on outside click of component subtree -
i'm aware of several solutions detecting 'outside' clicks react component - i.e. use dom elements' .contains
method see if event originated within dom tree - however, know of can detect such events 'outside' of actual component hierarchy? example, work portals above method not (since dom tree isn't representative of react tree).
edit: example:
<div> <div onoutsideclick={handleoutsideclick}> // onoutsideclick implementation todo <div> <button /> // same dom tree, same component tree, detected not outside (ding) </div> <div> <portal> <button /> // not same dom tree, same component tree, detected outside (bzzt) </portal> </div> </div> <button /> // not same component tree, nor dom tree, detected outside (ding) </div>
Comments
Post a Comment