Skip to content

Commit

Permalink
Mention useReducer as a cause of rerender in React.memo (reactjs#3576)
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim authored Mar 12, 2021
1 parent 9df2664 commit 54a331d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/docs/reference-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const MyComponent = React.memo(function MyComponent(props) {

If your component renders the same result given the same props, you can wrap it in a call to `React.memo` for a performance boost in some cases by memoizing the result. This means that React will skip rendering the component, and reuse the last rendered result.

`React.memo` only checks for prop changes. If your function component wrapped in `React.memo` has a [`useState`](/docs/hooks-state.html) or [`useContext`](/docs/hooks-reference.html#usecontext) Hook in its implementation, it will still rerender when state or context change.
`React.memo` only checks for prop changes. If your function component wrapped in `React.memo` has a [`useState`](/docs/hooks-state.html), [`useReducer`](/docs/hooks-reference.html#usereducer) or [`useContext`](/docs/hooks-reference.html#usecontext) Hook in its implementation, it will still rerender when state or context change.

By default it will only shallowly compare complex objects in the props object. If you want control over the comparison, you can also provide a custom comparison function as the second argument.

Expand Down

0 comments on commit 54a331d

Please sign in to comment.