Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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