Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed React Components!
You have completed React Components!
Preview
You can even use PropTypes to mark a prop as required or provide a default value if the prop isn’t provided.
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
So not only does PropTypes
validate the prop, but
0:00
you can also even make a prop required.
0:04
This can be extremely helpful
if you omit a prop altogether.
0:07
For example, if I delete the name and
0:12
score props pass the player,
our name and scores are blank.
0:15
And React doesn't warn us because the
missing props are not marked as required.
0:20
So to make sure that a warning is
shown if the prop isn't provided,
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up