Component Injection
What is Component Injection?#
Passing (or inject) a component into another component it's called Component Injection.
Example 1#
It look pretty much the same as in the function as prop component, except the prop we capitalize Hello because convention calls for us to capitalize the first letter of a component name. We also pass in props, an object, instead of a single string parameter, those are the only differences.
And Foo component will looks a lot more like a traditional React component.
Example 2#
Let's take a look at a advanced example, altered for component injection.
So well as how you use it.
As you can see, the DisplayPageWidthText component is "injected" into PageWidth as a prop named Width.
You could even pass a different component and get a completely different rendered output, thanks to the power of render callback.