Returning Another Component via Render Props

Let’s say you’re sending a button from a parent to a child using render props.  How do you properly render and place the returned button?

As it turns out, its quite easy.

Let’s say that this is your component which uses render props to return both the toggle state and the toggle button.

To use the above provider, you may be tempted (because of patterns) to do this.

However, because the parent has already rendered the button, the child needs only to place the rendered component as if it were any other variable.

That’s it.


Leave a Reply

Your email address will not be published. Required fields are marked *