reactjs / react.dev

The React documentation website
https://react.dev/
Creative Commons Attribution 4.0 International
11.05k stars 7.55k forks source link

Document memoization as alternative to componentWillReceiveProps #830

Open gaearon opened 6 years ago

gaearon commented 6 years ago

We get a lot of feedback that getDerivedStateFromProps is used for memoization which is not very ergonomic.

Let’s add a recipe about memoizing directly to the docs.

https://twitter.com/brian_d_vaughn/status/987443099537309696?s=20

We should probably use this package:

https://www.npmjs.com/package/memoize-one

It’s important to highlight that we usually recommend memoizing just the last value.

KenFoss commented 11 months ago

@gaearon Can I take this?