Skip to content

Commit 04a1bd4

Browse files
committed
Clarify child element rendering behaviour
1 parent 44b0b5f commit 04a1bd4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎src/content/learn/understanding-your-ui-as-a-tree.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ The tree is composed of nodes, each of which represents a component. `App`, `Fan
131131

132132
The root node in a React render tree is the [root component](/learn/importing-and-exporting-components#the-root-component-file) of the app. In this case, the root component is `App` and it is the first component React renders. Each arrow in the tree points from a parent component to a child component.
133133

134+
### How passing children affects component rendering {/*how-passing-children-affects-component-rendering*/}
135+
136+
When a component creates a child element directly in its own JSX , it creates a new React element each time it renders. When a component receives a child element through its `children` prop , React can reuse that element when the component updates its own state without its parent rendering again.
137+
138+
In the above example , `App` creates the `Copyright` and passes it to `InspirationGenerator` through `children`. If `InspirationGenerator` updates its own state without `App` rendering again , React can reuse the same `Copyright` element without rendering the `Copyright` again.
139+
140+
By contrast , if `App` creates <FancyText/> directly in its JSX , rendering `App` again creates a new element , React may render `FancyText` again as part of the render.
141+
142+
Passing children through props doesn't prevent all re-renders. A child can still render when its own state or context changes , or when its parent renders and creates a new element.
143+
134144
<DeepDive>
135145

136146
#### Where are the HTML tags in the render tree? {/*where-are-the-html-elements-in-the-render-tree*/}

0 commit comments

Comments
 (0)