Join Eve Porcello for an in-depth discussion in this video PropTypes, part of React.js Essential Training.
- [Instructor] In the last video,…we looked at how defaultProps can be used…to supply values when other values are not provided.…Another nice property checking feature…that we can include, is propTypes.…So, let me show you a situation…where these might come in handy.…So, here on line four, our bookList is an array.…Let's change this to being an object, an object of objects,…and we'll say books is the key for this object,…and it's returning this big array.…
There we go.…So, let me give that a save.…Now, pretty immediately we're going to notice…that books.map is not a function,…because we're trying to map over this object…and that's not working like it would for an array.…We can't use the array method .map on it.…So, this might be a nice time for including property types…to make sure that all of our properties…that are being supplied are of the right type.…So, let me hit Control Z a few times…to get back to our bookList array.…
So, there we are, back to normal.…This is rendering as expected…and we're going to import PropTypes…
- 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?
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.