I have 3 components. One parent component and two child components (A,B). The first child component A has a button that triggers a parent components function. The parent has a switch either to display child component B or not. If the child component B shall be visible it becomes mounted. The function child A called from parent now executes a function in component B.
I tried to realise it by providing a ref attribute on child component B. But as it is not mounted for a good reason on init this.refs
is empty.
How can I achieve this without mounting all possible child components B (or later C,D,E) initially.
It is important that the onClick event in child A always triggers the referenced events.
Can anybody give me a hint to solve my logical problem?