Join Carl Peaslee for an in-depth discussion in this video componentWillReceiveProps, part of React: Lifecycles.
- [Instructor] In this video,…we're going to be talking about the first…of our update live cycle methods,…and this is componentWillReceiveProps.…ComponentWillReceiveProps is, as I'm sure you've guessed,…called when your component will receive props.…Now, I also want to point out that while…componentWillRecieveProps is primarily called…when your component will receive props,…there are also occasions where it might get called…because of a state change on a parent component.…So, if you have something that's happening…in componentWillReceiveProps,…and you're getting problems where…maybe it's getting called one too many times,…that's something you should be aware of.…
So, whatever is happening in componentWillReceiveProps,…you should make sure that it's basically a function…of the props that are being passed to that component.…And if an extra call to it gets made,…it won't throw a problem in your application.…Okay, so one of the primary applications…of componentWillReceiveProps is to handle some…change to state because you have a state variable…
Carl Peaslee helps you build a number of small reusable components that will be useful in future projects. Along the way, he discusses the syntax and uses of lifecycle methods, how state affects React lifecycles and your apps, and how to set static display name, default props, and initial state. Plus, learn how to gather performance data and improve performance by minimizing component updates.
- Overview of React lifecycles
- Initial state
- Default props
- Mounting: componentWillMount, componentDidMount, and render
- Updating: shouldComponentUpdate, componentWillUpdate, and componentDidUpdate
- Controlling component updates
- Using react-addons-perf to get performance data