3

I'm trying to inject some Javascript into a website build with React. The code needs access to the React Renderer.

I'm running the ReactDevTools extension, which allows me to execute code like this:

var elementData = window.__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent.elementData.values(); 
var elts = []; var done = false;
while (!done) {   
    var iter = elementData.next();   
    done = iter.done;
    elts.push(iter.value); 
}

window.componentName = elts.filter(function(elt) { return elt != null && elt.name=="componentName"; })[0];
window.propName = window.componentName.props.propName;

Is there a way to access components with a JS injection without running the ReactDevTools extension?

0 Answers0