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?
<Button />is a virtual DOM representation of said component.thisin thatButton'srender()is an instance of theButtoncomponent. There is only one active instance for one<Button />, but React reserves the right to unmount, mount, and recreate that instance under different circumstances.Buttoncomponent might not render its children.Appto change theButton's output, a) by passing props, b) by setting state using refs, c) by setting context. All three assume thatButtonchanges its output based on those mechanisms.Edit: 3. -> The other way is indirectly via architectures such as flux and redux. ;)