From 5aee222d562ccac3b2c7e41de9bf2a37e072ff97 Mon Sep 17 00:00:00 2001 From: Peter Nycander Date: Sun, 17 Mar 2019 19:40:58 +0100 Subject: [PATCH] Adds a sentence to decrease FUD about useMemo Dan listed useMemo as a solution for avoiding re-triggering an effect https://github.com/facebook/react/issues/14476#issuecomment-471199055 If this is an accepted use case, the docs should reflect it. --- content/docs/hooks-reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/hooks-reference.md b/content/docs/hooks-reference.md index 5bf44094c02..e1d13a97c98 100644 --- a/content/docs/hooks-reference.md +++ b/content/docs/hooks-reference.md @@ -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 >