A top-level App
component returns <Button />
from its render()
method.
-
What is the relationship between
<Button />
andthis
in thatButton
’srender()
? -
Does rendering
<Button><Icon /></Button>
guarantee that anIcon
mounts? -
Can the
App
change anything in theButton
output? What and how?
<Button />
is a virtual DOM representation of said component.this
in thatButton
'srender()
is an instance of theButton
component. There is only one active instance for one<Button />
, but React reserves the right to unmount, mount, and recreate that instance under different circumstances.Button
component might not render its children.App
to change theButton
's output, a) by passing props, b) by setting state using refs, c) by setting context. All three assume thatButton
changes its output based on those mechanisms.Edit: 3. -> The other way is indirectly via architectures such as flux and redux. ;)