Access React tree from within a component
Is there a way to access the React tree down a component from within it? For instance when I use the React-devtool extension I am able to navigate along the React tree. Is it possible to do such navigation from within the code of a component to know everything below it?
I know about children, but it does not work when parents components simply render children components, ie in Parent component I have something like
render() {
<Child1 />
}
then in Child1 component I have
render() {
<Child2 />
}
etc.
and I'd like to know from Parent that there is below a Child1 and then a Child2 .
I have had a look at this._reactInternalInstance._instance._renderedComponent._currentElement where I can see that, for instance, Parent renders a Child1 . But from this I cannot go further to see what Child1 renders.
上一篇: 在React中动态创建组件
下一篇: 从组件内访问React树
