- [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.…
Author
Released
12/18/2018- Refactoring elements with JSX
- Creating components
- Adding component properties and methods
- Displaying child components
- Working with props and state
- Conditional rendering
Skill Level Intermediate
Duration
Views
Related Courses
-
React: Ecosystems
with Emmanuel Henri12m 21s Intermediate
-
Introduction
-
1. What Is React?
-
What is React?59s
-
Inspect React sites1m 31s
-
-
2. Introduction to React Elements
-
Install create-react-app1m 28s
-
Generate a project3m 2s
-
Create React elements4m 20s
-
-
3. React Components
-
Create a React component2m 16s
-
Add component properties3m 35s
-
Add custom methods1m 39s
-
Create function components3m 53s
-
-
4. Props and State
-
Compose components4m 48s
-
Display child components4m 42s
-
Introducing state3m 30s
-
Using setState4m 16s
-
Pass state as props2m 58s
-
Conditional rendering3m 5s
-
-
5. Additional Library Features
-
Component life cycle3m 10s
-
Fetching data4m 43s
-
Accessibility2m 6s
-
Forms4m 7s
-
Default props3m 29s
-
PropTypes3m 56s
-
Modularizing code3m 58s
-
Build the app2m 1s
-
-
Conclusion
-
Next steps36s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Default props