I would like to be able to read the data associated with a react component on a 3rd party web page that is using React. I want to be able to read this using javascript within the Chrome Dev console tools on that page. Is this possible?
For example, I have a TR element which is drawn by react. I would like to get this TR using regular document.getElementById() and then use that to get the underlying react data.
Using the React Developer Tools Extension I can see my data just sitting there under props.data - how can I read that?
Please note that I am treating React as a black box here.
Note: per this answer I can get a react object from a DOM element, and it works: React - getting a component from a DOM element for debugging
window.findReactComponent = function(el) {
for (const key in el) {
if (key.startsWith('__reactInternalInstance$')) {
const fiberNode = el[key];
return fiberNode && fiberNode.return && fiberNode.return.stateNode;
}
}
return null;
};
But having gotten that, how can I get to props?