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.

G H Mahimaanvita
16,234 PointsNot sure what exact keyword does
<Route path="/courses" render={() => <Redirect to="/courses/html" />} />
<Route path="/courses/html" render={() => <HTML />} />
<Route path="/courses/css" render={() => <CSS />} />
<Route path="/courses/javascript" render={() => <JavaScript />} />
I did not add the 'exact' keyword in path="/courses"
so I expected that even if i click the link to /courses/css or javascript I would be redirected to /courses/html
Why didn't that happen?
Moreover, even if I click the Courses link after css and javascript it doesn't redirect to html!
It works if I add the 'exact' keyword
I thought the 'exact' keyword prevents routing if the url dosent match exactly.... but dosen't it look like it's doing the opposite here?
1 Answer

okilydokily
11,107 PointsI think it's because the method only works if you aren't already in a 'courses' path, otherwise it won't rerender. Actually, if you don't have 'exact' and you type in a '/courses/css' path in the browser when you aren't already in a courses path it will redirect you to '/courses/html'