ReactJS - How to get the entire rendering tree

How can I access all elements of the rendering tree of the reacting component, but it does .props.childrenn’t work, and I can’t use it refs.

Here is an example of what I'm trying to achieve.

// the following is the code inside the `render` function
// for a component called AwesomeLayer
// this.draw is the drawing function for ctx.
<LayoutLayer>
  <SomeOtherLayer>
    <Drawable onAnimationFrame={this.draw} />
  </SomeOtherLayer>
</LayoutLayer>

Now I have a top-level container named SurfaceLayer The surface layer should visit all its children one by one on propsChange, and then find all the drawings and cache answers for future rafs on any update that it is cleared.

But if SurfaceLayerconsists of the following

<SurfaceLayer>
    <AwesomeLayer />
</SurfaceLayer>

I will not refer to drawable, because the children of the AwesomeLayer node will be undefined. PS This code may be used by others, so I won’t rely on explicit links as they will cause more errors.

, singleton store , ui (, , ), ?

+4
1

, .js, , . , refs , , . , AwesomeLayer , , getAwesomeChildren() AwesomeLayer.

0
source

All Articles