Go ProSign in
Autoplay
Hide playlist

    Refactor componentWillReceiveProps() to getDerivedStateFromProps() in React 16.3

    Andrew Del PreteAndrew Del Prete
    4:06

    The componentWillReceiveProps() method is being deprecated in future version of React (17). Many of us use this method day-to-day to check for incoming prop changes, store state, and to invoke side effects like logging or fetching data from a server.

    In this lesson, we'll look at how to refactor an existing component that uses componentWillReceiveProps() to instead use getDerivedStateFromProps() and componentDidUpdate().

    Additional Resources: https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#migrating-from-legacy-lifecycles

    You must be a Member to view code