Skip to content

Instantly share code, notes, and snippets.

@nestoralonso
Last active July 15, 2018 00:45
Show Gist options
  • Save nestoralonso/22b70962fdbe8c1556491aea6c332e84 to your computer and use it in GitHub Desktop.
Save nestoralonso/22b70962fdbe8c1556491aea6c332e84 to your computer and use it in GitHub Desktop.
get react object from the DOM
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