fix(curriculum): clarify useMemo rerender behavior (#67350)

Signed-off-by: Caio Bittencourt <caiolucasbittencourt@hotmail.com>
Co-authored-by: majestic-owl448 <26656284+majestic-owl448@users.noreply.github.com>
This commit is contained in:
Caio Bittencourt
2026-05-13 15:42:25 -03:00
committed by GitHub
parent 169764fc3f
commit af87e4ef14

View File

@@ -124,9 +124,7 @@ function ExpensiveSquare({ num }) {
export default ExpensiveSquare;
```
This will make sure the function is memoized by caching the result, so calculation happens only when the `num` variable changes, not when anything changes in the component it's being used in.
The `calculateSquare` function call is not running any time `timer` changes anymore but on the initial render and when `num` changes.
This will make sure the function is memoized by caching the result. Even though the `ExpensiveSquare` component still re-renders every time the parent's `timer` state updates, the `calculateSquare` computation only re-runs on the initial render and when `num` changes.
# --questions--