From 7d1f5b48dc07666b94cf58abf3ccbfe7285a2f0e Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 19 Mar 2019 22:03:28 +0000 Subject: [PATCH] Document useContext bailout strategy --- content/docs/hooks-reference.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/docs/hooks-reference.md b/content/docs/hooks-reference.md index f2cc087d43c..98c2e14c016 100644 --- a/content/docs/hooks-reference.md +++ b/content/docs/hooks-reference.md @@ -188,6 +188,8 @@ Don't forget that the argument to `useContext` must be the *context object itsel * **Incorrect:** `useContext(MyContext.Consumer)` * **Incorrect:** `useContext(MyContext.Provider)` +A component calling `useContext` will always re-render when the context value changes. If re-rendering the component is expensive, you can [optimize it by using memoization](https://github.com/facebook/react/issues/15156#issuecomment-474590693). + >Tip > >If you're familiar with the context API before Hooks, `useContext(MyContext)` is equivalent to `static contextType = MyContext` in a class, or to ``.