A top-level App component returns <Button /> from its render() method.
-
What is the relationship between
<Button />andthisin thatButton’srender()? -
Does rendering
<Button><Icon /></Button>guarantee that anIconmounts? -
Can the
Appchange anything in theButtonoutput? What and how?
The App component's render method returns a Button Element, which is not the same as Button Component class. This Button element instance has this structure -
When the element is actually mounted, React will use this information to create a Button Component class instance, which will be the value of
thisinside the Button Component'srender.The will be mounted if App has mounted Button and the
renderof Button returns{this.props.children}.Yes, App can change what Button renders through props, or using a HOC on it.