Join Eve Porcello for an in-depth discussion in this video Default props, part of React.js Essential Training.
- [Instructor] Let's make some adjustments…to our library app…to make it even more ready for production.…So, I'm going to take everything…that I've commented out before, and uncomment it.…I also will get rid of the Favorite Color Form.…We'll say goodbye to that.…And instead, render the Library,…and we'll make sure to pass books as a property…with a value of bookList.…
Great, so now we're back to where we were.…The next thing I want to do is scroll to the top…of our Library component,…and right beneath our, or right above our state rather,…we will add a static property called defaultProps.…And defaultProps is going to have a key of books,…and it'll have a value of just a simple object.…So, we'll say title,…and we'll say Tahoe Tales, author, Chet Whitley,…and finally, pages, 1,000.…
At this point we've added default props…to our library component.…Now what's the point of this?…Well, we're adding this so that in the event…that there's no value available for books,…we're going to use this default value instead.…So let me show you how that looks.…
- Refactoring elements with JSX
- Creating components
- Adding component properties and methods
- Displaying child components
- Working with props and state
- Conditional rendering
Skill Level Intermediate
1. What Is React?
2. Introduction to React Elements
3. React Components
4. Props and State
5. Additional Library Features
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
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.