Skip to content

Commit da72036

Browse files
mfix22alexkrolick
authored andcommitted
Update hooks-faq to use React.memo instead of React.pure (#1305)
1 parent 45eb0d5 commit da72036

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

content/docs/hooks-faq.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ There are a few more heuristics, and they might change over time as we fine-tune
113113

114114
* `getDerivedStateFromProps`: Schedule an update [while rendering](#how-do-i-implement-getderivedstatefromprops) instead.
115115

116-
* `shouldComponentUpdate`: See `React.pure` [below](#how-do-i-implement-shouldcomponentupdate).
116+
* `shouldComponentUpdate`: See `React.memo` [below](#how-do-i-implement-shouldcomponentupdate).
117117

118118
* `render`: This is the function component body itself.
119119

@@ -319,17 +319,17 @@ Yes. See [conditionally firing an effect](/docs/hooks-reference.html#conditional
319319

320320
### How do I implement `shouldComponentUpdate`?
321321

322-
You can wrap a function component with `React.pure` to shallowly compare its props:
322+
You can wrap a function component with `React.memo` to shallowly compare its props:
323323

324324
```js
325-
const Button = React.pure((props) => {
325+
const Button = React.memo((props) => {
326326
// your component
327327
});
328328
```
329329

330-
It's not a Hook because it doesn't compose like Hooks do. `React.pure` is equivalent to `PureComponent`, but it only compares props. (You can also add a second argument to specify a custom comparison function that takes the old and new props. If it returns true, the update is skipped.)
330+
It's not a Hook because it doesn't compose like Hooks do. `React.memo` is equivalent to `PureComponent`, but it only compares props. (You can also add a second argument to specify a custom comparison function that takes the old and new props. If it returns true, the update is skipped.)
331331

332-
`React.pure` doesn't compare state because there is no single state object to compare. But you can make children pure too, or even [optimize individual children with `useMemo`](/docs/hooks-faq.html#how-to-memoize-calculations).
332+
`React.memo` doesn't compare state because there is no single state object to compare. But you can make children pure too, or even [optimize individual children with `useMemo`](/docs/hooks-faq.html#how-to-memoize-calculations).
333333

334334

335335
### How to memoize calculations?

0 commit comments

Comments
 (0)