I am currently in the process of designing the interface for a game engine that is written in JavaScript and ReactJS.
If a game object has a texture, the source of the texture will show up on the game object. For that to work, a game object needs to have the reference of the texture or more specifically the source of a texture. What I'm hoping for is to have a JSX snippet like the following one.
<GameObject>
<Texture source="myimage.png" />
</GameObject>
The best solution I could come up with to get the reference is to have the texture as a prop, like so:
<GameObject texture={<Texture source="myimage.png" />} />
If the game engine-specific terminology is a bit too bewildering, think of it as a caption component inside a button component, where the caption component has specific data the button needs to access.
My question boils down to this: Is it possible to access children's prop after the children have been mounted without hacks or being an anti-pattern?