Skip to content

Commit

Permalink
Update useCallback example to clarify parent
Browse files Browse the repository at this point in the history
Update paragraph to indicate that `<App />` is the parent.
  • Loading branch information
alexoragz authored Jul 15, 2021
1 parent 46e80f1 commit b28eb7e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/docs/useCallback.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ The following example will form the basis of the explanations and code snippets

<Editor noInline code={Starter} />

In the example above, the parent component, `<Age />` is updated (and re-rendered) whenever the "Get older" button is clicked.
Consequently, the `<Instructions />` child component is also re-rendered because the `doSomething` prop is passed a
In the example above, the parent component, `<App />` is updated (and re-rendered) whenever the "Get older" button is clicked.
Consequently, `<Age />` and `<Instructions />` child components are also re-rendered. `<Instructions />` is re-rendered because the `doSomething` prop is passed a
new callback, with a new reference. This can be seen from the random text colour which changes whenever the state value `age` is updated.

> NB: Even though the `Instructions` child component uses `React.memo` to optimize performance, it is still re-rendered.
Expand Down

0 comments on commit b28eb7e

Please sign in to comment.