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 4 Basics Going Further with Routing Displaying 404 Error Routes using Switch

Pierre Smith
Pierre Smith
11,842 Points

Switch doesn't work for nested routes.

In the video the mention that using the switch along with a default route component will catch any url's that don't exist and default it to the NotFound component but this is not true for nested components is it possible to someone write it once at the top of the application and so that we don't have to write a switch component for every nested url?

1 Answer

Here's a similar question/discussion on Stack Overflow that might get you pointed in the right direction:

Nested routes with react router v4