Browse Source

Updating the docs to reflect the fact that React.memo can be used wit… (#3159)

* Updating the docs to reflect the fact that React.memo can be used with both class and functional components

* removed misleading para
main
kamlesh tajpuri 5 years ago
committed by GitHub
parent
commit
25cc703d1f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      content/docs/reference-react.md

4
content/docs/reference-react.md

@ -124,9 +124,9 @@ const MyComponent = React.memo(function MyComponent(props) {
});
```
`React.memo` is a [higher order component](/docs/higher-order-components.html). It's similar to [`React.PureComponent`](#reactpurecomponent) but for function components instead of classes.
`React.memo` is a [higher order component](/docs/higher-order-components.html).
If your function 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.
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.

Loading…
Cancel
Save