Browse Source

Clarify it's not a recommended approach

main
Dan Abramov 6 years ago
committed by GitHub
parent
commit
846ab6c383
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      content/blog/2018-06-07-you-probably-dont-need-derived-state.md

5
content/blog/2018-06-07-you-probably-dont-need-derived-state.md

@ -231,6 +231,11 @@ class Example extends Component {
filterText: "",
};
// *******************************************************
// NOTE: this example is NOT the recommended approach.
// See the examples below for our recommendations instead.
// *******************************************************
static getDerivedStateFromProps(props, state) {
// Re-run the filter whenever the list array or filter text change.
// Note we need to store prevPropsList and prevFilterText to detect changes.

Loading…
Cancel
Save