Learning About React and Derived State

08/26/20191 Min Read — In React.js, JavaScript, Lab

Today I've been trying to refactor a class-based component that uses getDerivedStateFromProps().

I originally used this lifecycle method to replace the deprecated componentWillMount(). You can read more about that in the blog post about async rendering.

But then I realized that erasing state when props change is an anti-pattern.

Now I'm trying to come up with another solution.

Further Reading