I'm currently facing a problem while developing a Chrome Extension. This extension is used on a ReactJS based website. I need to scrap some data from the page. He is an example of the page.
<div class="UserWallet">
<tbody>
<tr class"Trans"><td>...</td></tr>
...
<tbody>
</div>
When I use the Chrome inspector, I can see that my div class="UserWallet">
has a property __reactInternalInstance
. I found a function findReact(element)
used to get the React Instance. This function is used in an other Chrome Extension called Steemit-More-Info. I have the exact same function and a use the same HTML element as parameter but my function is not working. When I do $(".UserWallet)"
, the result doesn't contains the property __reactInternalInstance
. But in the other extension, it's working with the same JQuery code and the same findReact function.
Here is the code for findReact.
var findReact = function(dom) {
for (var key in dom) {
if (key.startsWith("__reactInternalInstance$")) {
var compInternals = dom[key]._currentElement;
var compWrapper = compInternals._owner;
var comp = compWrapper._instance;
return comp;
}
}
return null;
};
Has anyone ever faced that problem? Is there a special library that I need to include in my extension to be able to scrap the reactInstance?
Thank you,
cedric_g