简体   繁体   中英

Find all instances of React component by Tag name

I'm trying to write a plugin for a webpage that uses React. I have access to React and ReactDOM .

I need to find all instances of the PageWrapper React component for this particular page.

I can do this using the React dev tools for Google Chrome with the search bar, but I want to be able to do this in JavaScript.

PageWrapper React开发工具

Is there any way of doing this in JavaScript? Something like FindAllInstancesOfReactComponent(tagName) would be perfect.

You may try using reactDOM.

ReactDOM.findDOMNode(component)

https://reactjs.org/docs/react-dom.html#finddomnode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM