From the course: React Essential Training
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Solution: Creating a route - React.js Tutorial
From the course: React Essential Training
Solution: Creating a route
(upbeat rhythmic music) - [Instructor] Alright, let's go over our solution. So we wanted to create a new route, we wanted to render a page component, and we wanted to make sure that the link is to the contact route from the header. So anytime I want to create a route, I go to the app folder, I create a new folder called "Contact." Within it, we have a default export typically in a file called "page." (keys clicking) And we export a component. In React, we want to always make sure that our component name is capitalized. That is a React thing, not a Next.js thing necessarily. Let's go ahead and return a main element, and we'll say, "Contact us!" Great. So this should be exported from that route. If I go to the correct folder, I make sure all of my node modules are installed, and I run "npm run dev." This should run. We go back to localhost:3000, it looks like it's on the hotels route, that's okay. But if I go to contact, we should see "Contact Us!" Nice. What happens if I go to a route…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.