Skip to content

Commit

Permalink
Merge pull request #28 from alexoragz/patch-1
Browse files Browse the repository at this point in the history
Update `useCallback` example to clarify parent
  • Loading branch information
ohansemmanuel authored Aug 27, 2023
2 parents d6eea1c + b28eb7e commit cf7096b
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 @@ -26,8 +26,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 cf7096b

Please sign in to comment.