Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Router Basics Going Further with Routes Passing props to Routes

Lucas Santos
Lucas Santos
19,315 Points

Does this mean that when passing in Props to a Route you don't need to define what kind of prop it takes?

Normally when passing in Props to a component we would need to define it's structure with PropTypes then define it's type such as String, Array or Shape for the objects.

example:

Greeting.propTypes = {
  name: React.PropTypes.string,
};

<Component name="Bob" />

Now when he passed in the props to Routes we did not need to define anything... does this work like getDefaultProps() ?

Christian Blume
Christian Blume
10,424 Points

Hey Lucas,

defining which props a Component will receive isn't mandatory. It is good style though and can prevent you from making mistakes.

So, to answer your question: No, you definitely don't need to specify which props CourseContainerwill receive.