Last active
July 15, 2018 00:45
-
-
Save nestoralonso/22b70962fdbe8c1556491aea6c332e84 to your computer and use it in GitHub Desktop.
get react object from the DOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getReactElement = (dom) => { | |
for (var key in dom) { | |
if (!key.startsWith("__reactInternalInstance$")) continue; | |
var compInternals = dom[key]._currentElement; | |
var compWrapper = compInternals._owner; | |
var comp = compWrapper._instance; | |
return comp; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment