Skip to content

Commit

Permalink
Adds a sentence to decrease FUD about useMemo
Browse files Browse the repository at this point in the history
Dan listed useMemo as a solution for avoiding re-triggering an effect
facebook/react#14476 (comment)
If this is an accepted use case, the docs should reflect it.
  • Loading branch information
peternycander committed Mar 17, 2019
1 parent 88f21a3 commit 5aee222
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/docs/hooks-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ Remember that the function passed to `useMemo` runs during rendering. Don't do a

If no array is provided, a new value will be computed on every render.

**You may rely on `useMemo` as a performance optimization, not as a semantic guarantee.** In the future, React may choose to "forget" some previously memoized values and recalculate them on next render, e.g. to free memory for offscreen components.
**You may rely on `useMemo` as a performance optimization, not as a semantic guarantee.** In the future, React may choose to "forget" some previously memoized values and recalculate them on next render, e.g. to free memory for offscreen components. This means that a value from `useMemo` in a `useEffect` dependency list may trigger the effect without any "real" changes. However, if an additional run of that effect does not break your component, you should feel free to use it in that regard.

> Note
>
Expand Down

0 comments on commit 5aee222

Please sign in to comment.