Set your component's default props.
- [Instructor] Default props is another static method…that's available to any React component,…and it's also a method that, once again,…might not necessarily be known…as a member of the lifecycle methods,…but it does happen each time a React component is created.…The purpose of default props…is to ensure that when a component begins its existence,…it has certain props available to it right away.…So default props will be used instead of pass down props…if the pass down props are undefined.…They won't be overrided if they're known.…So why am I going to use default props?…Well, let's look at a few examples.…
In many cases, default props might be useful if,…for instance, you had an array…that needed to be looped through once the component begins,…or if you had some sort of data type…that you need to make sure exists when the component starts,…otherwise it might cause an error.…So let's go to our components…and try making some default props.…Once again, just like with display name,…we can set it in two different ways.…
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
Skill Level Intermediate
React.js: Building an Interfacewith Ray Villalobos1h 21m Intermediate
1. Overview of Lifecycles
2. Defaults, Initialization, and Construction
5. Optimizing Components
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.