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

When I add a prop to a NavLink in my Courses page I get the following error: Unknown prop `course` on <a> tag.

I'm trying to add links to individual teachers where you could pass in a parameter and link to the course page, but only the course that is passed in as a parameter will be displayed. But when I add to my a <NavLink to="courses" course={course.id}> See course here </NavLink> in my Teachers.js file for each teacher, i get the following error: Warning: Unknown prop course on <a> tag. Remove this prop from the element. The video makes it look so easy to pass a param to a route but I'm having a lot of trouble

2 Answers

Hi Julia, Which video is this question for? If you are learning URL params, you'll want to have the variable course.id added to the route string: <NavLink to={`/courses/${course.id}`}>See courses here</NavLink> to match the route path/courses/:courseId. P.S., Hopefully when you hover over the link you'll see something like. localhost:8080/courses/1 where 1 is course.id

I get these two errors: Warning: [react-router] Location "/courses" did not match any routes Uncaught TypeError: Cannot read property 'courseId' of undefined

I think I might put my code in a repository so there is a better reference