About the removal of componentWillReceiveProps: you should be able to handle its uses with a combination of getDerivedStateFromProps and componentDidUpdate, see the React blog post for example migrations. And yes, the object returned by getDerivedStateFromProps updates the state similarly to an object passed to setState.

In case you really need the old value of a prop, you can always cache it in your state with something like this:

state = {
  cachedSomeProp: null
  // ... rest of initial state
};

static getDerivedStateFromProps(nextProps, prevState) {
  // do things with nextProps.someProp and prevState.cachedSomeProp
  return {
    cachedSomeProp: nextProps.someProp,
    // ... other derived state properties
  };
}

Anything that doesn't affect the state can be put in componentDidUpdate, and there's even a getSnapshotBeforeUpdate for very low-level stuff.

UPDATE: To get a feel for the new (and old) lifecycle methods, the react-lifecycle-visualizer package may be helpful.

Answer from Oblosys on Stack Overflow
🌐
React
legacy.reactjs.org › docs › react-component.html
React.Component – React
This method doesn’t have access to the component instance. If you’d like, you can reuse some code between getDerivedStateFromProps() and the other class methods by extracting pure functions of the component props and state outside the class definition.
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › react-js-static-getderivedstatefromprops
React.js static getDerivedStateFromProps() - GeeksforGeeks
July 23, 2025 - getDerivedStateFromProps(props, state) Parameters: props: The updated props passed from the parent component · state: The current state of the component · Return: Returns an object to update the component state or null. getderivedFromProps ...
Discussions

How to use lifecycle method getDerivedStateFromProps as opposed to componentWillReceiveProps
It looks like componentWillReceiveProps is going to be completely phased out in coming releases, in favor of a new lifecycle method getDerivedStateFromProps:static getDerivedStateFromProps(). Upon More on stackoverflow.com
🌐 stackoverflow.com
Discussion: componentWillReceiveProps vs getDerivedStateFromProps
Hello We have found a scenario where the removal of componentWillReceiveProps will encourage us to write worse code than we currently do. We currently consider props to be a valid form of input and state for our component. If a component... More on github.com
🌐 github.com
97
March 28, 2018
how to use getDerivedStateFromProps instead of componentWillReceiveProps in React
I like to update my code to use getDerivedStateFromProps instead of componentWillReceiveProps as the I am receiving deprecated error. The component is receiving a date prop and every time the date is More on stackoverflow.com
🌐 stackoverflow.com
How does `static getDerivedStateFromProps` work?

React always knows exactly what component instance it's currently rendering. But, in order to prevent potentially problematic usage patterns, yes, the getDerivedStateFromProps lifecycle method must be defined as static, so you cannot reference this inside. You're supposed to only look at the (latestProps, latestState) parameters, and determine what state updates if any are needed.

More on reddit.com
🌐 r/reactjs
3
2
October 31, 2018
🌐
Medium
medium.com › swlh › lifecycle-state-and-getderivedstatefromprops-761b3a19c4e
Lifecycle, state, getDerivedStateFromProps and Hooks | by Thomas Rubattel | The Startup | Medium | The Startup
December 17, 2022 - As part of the migration process, do write your components in a more functional programming way. React Hooks help in that regard. Make sure your render function is pure. Replace componentWillReceiveProps by getDerivedStateFromProps which also needs to be pure, or by React Hooks.
🌐
Jasonkang14
jasonkang14.github.io › posts › react › react-life-cycle-get-derived-state-from-props-with-mobx
React Lifecycle - Using getDerivedStateFromProps with React Native and MobX - Blog by Jason Kang
static getDerivedStateFromProps(props, state) { if (toJS(props.MainScreenStore.snsPostArr[0]).length !== state.prPostArr.length) { return { prPostArr: toJS(props.MainScreenStore.snsPostArr[0]), likedPostSet: new Set(toJS(props.MainScreenStore.snsPostArr[1])) } } return null; }
🌐
DhiWise
dhiwise.com › post › best-practices-for-using-getderivedstatefromprops-in-your-react-applications
The Role of getDerivedStateFromProps in the React
October 27, 2023 - The getDerivedStateFromProps method takes two parameters: nextProps and prevState. nextProps is an object representing the new props that the component is receiving, and prevState is an object representing the current state of the component.
🌐
TutorialsPoint
tutorialspoint.com › home › reactjs › reactjs getderivedstatefromprops method
ReactJS - static getDerivedStateFromProps() Method
February 13, 2026 - When the user ID changes, the getDerivedStateFromProps function resets the email. The function handleUserIDChange simulates a user ID change. The App component sets the Form and manages changes to the user ID. This is a basic example, and we can change it to meet our specific requirements. Now we will create a simple counter app in which the initial count is given as a parameter ...
Top answer
1 of 4
119

About the removal of componentWillReceiveProps: you should be able to handle its uses with a combination of getDerivedStateFromProps and componentDidUpdate, see the React blog post for example migrations. And yes, the object returned by getDerivedStateFromProps updates the state similarly to an object passed to setState.

In case you really need the old value of a prop, you can always cache it in your state with something like this:

state = {
  cachedSomeProp: null
  // ... rest of initial state
};

static getDerivedStateFromProps(nextProps, prevState) {
  // do things with nextProps.someProp and prevState.cachedSomeProp
  return {
    cachedSomeProp: nextProps.someProp,
    // ... other derived state properties
  };
}

Anything that doesn't affect the state can be put in componentDidUpdate, and there's even a getSnapshotBeforeUpdate for very low-level stuff.

UPDATE: To get a feel for the new (and old) lifecycle methods, the react-lifecycle-visualizer package may be helpful.

2 of 4
63

As we recently posted on the React blog, in the vast majority of cases you don't need getDerivedStateFromProps at all.

If you just want to compute some derived data, either:

  1. Do it right inside render
  2. Or, if re-calculating it is expensive, use a memoization helper like memoize-one.

Here's the simplest "after" example:

import memoize from "memoize-one";

class ExampleComponent extends React.Component {
  getDerivedData = memoize(computeDerivedState);

  render() {
    const derivedData = this.getDerivedData(this.props.someValue);
    // ...
  }
}

Check out this section of the blog post to learn more.

Find elsewhere
🌐
Medium
medium.com › @farihatulmaria › what-is-getderivedstatefromprops-props-state-as-a-lifecycle-in-reactjs-a06594262ea4
What is getDerivedStateFromProps( props,state) as a lifecycle in ReactJs? | by Farihatul Maria | Medium
October 5, 2024 - The purpose of getDerivedStateFromProps() is to allow developers to update the component's state based on changes in the props. This is particularly useful in situations where the state of a component is dependent on the props.
🌐
GitHub
github.com › reactjs › react.dev › issues › 721
Discussion: componentWillReceiveProps vs getDerivedStateFromProps · Issue #721 · reactjs/react.dev
March 28, 2018 - static getDerivedStateFromProps(nextProps, prevState){ if (this.state.visible === true && newProps.visible === false) { registerLog('dialog is hidden'); } return { visible : nextProps.visible }; }
Author   arieh
🌐
Larry-price
larry-price.com › blog › 2018 › 06 › 27 › how-to-use-getderivedstatefromprops-in-react-16-dot-3-plus
How to Use getDerivedStateFromProps in React 16.3+ - Larry Price
getDerivedStateFromProps is invoked every time a component is rendered. It takes in two arguments: the next props object (which may be the same as the previous object) and the previous state object of the component in question.
🌐
DigitalOcean
digitalocean.com › community › tutorials › react-get-derived-state
Using Derived State in React | DigitalOcean
July 1, 2018 - Instead of calling setState like in the first example, getDerivedStateFromProps simply returns an object containing the updated state.
🌐
TutorialsPoint
tutorialspoint.com › reactjs-getderivedstatefromprops-method
ReactJS – getDerivedStateFromProps() Method
March 18, 2021 - <Show email="qwerty@gmail.com" /> : null} </div> ); } } class Show extends React.Component { constructor() { super(); this.state = { email: '', }; } static getDerivedStateFromProps(props, state) { console.log('getDerivedStateFromProps method is called'); return { email: props.email }; } render() { return ( <div> <h3>Email: {this.state.email}</h3> </div> ); } } export default App;
🌐
HackerNoon
hackernoon.com › replacing-componentwillreceiveprops-with-getderivedstatefromprops-c3956f7ce607
Replacing ‘componentWillReceiveProps’ with ‘getDerivedStateFromProps’ | HackerNoon
May 13, 2018 - programming#react#javascript#reactjs#componentwillreceiveprops#getderivedstatefromprops · Arweave · ViewBlock · Terminal · Lite · Coderoad · Devfaq · Thinbug · Errorsbase · Openweaver · Shijianchuo · Hashnode · Digraph · Learnrepo · Openweaver ·
🌐
TutorialsPoint
tutorialspoint.com › article › reactjs-getderivedstatefromprops-method
ReactJS &ndash; getDerivedStateFromProps() Method
March 18, 2021 - : null} ); } } class Show extends React.Component { constructor() { super(); this.state = { email: '', }; } static getDerivedStateFromProps(props, state) { console.log('getDerivedStateFromProps method is called'); return { email: props.email }; } render() { return (
🌐
O'Reilly
oreilly.com › library › view › learn-react-with › 9781789610253 › 7cc5c5d7-862b-43a1-bcf8-857caf15616c.xhtml
getDerivedStateFromProps - Learn React with TypeScript 3 [Book]
public static getDerivedStateFromProps(props: {}, state: IState) { console.log("getDerivedStateFromProps", props, state); return null;}
🌐
Rheinwerk Computing
blog.rheinwerk-computing.com › the-component-lifecycle-in-react
The Component Lifecycle in React
March 19, 2025 - In the example above, you add the initial property to the state. You use this property to check if the props have changed. In the getDerivedStateFromProps method, you first output the information that the function was called.