Defining Routes

Developed with
Start course

This module looks at how to Route in React. You’ll be looking at linking components, creating dynamic links, parameterized routes, and how to install the React Router DOM.

Learning Objectives 

The objectives of this module are to provide you with an understanding of: 

  • How to install the React Router DOM 
  • Hooks in React  
  • How to create restful services  
  • How to use an Effect Dependency Array  
  • How to hand errors in data requests  
  • How to send data   

Intended Audience  

This learning path is aimed at all who wish to learn how to use the ReactJS framework.  


It is essential you understand the face of contemporary web development to attend this course. You should also have JavaScript experience, along with good HTML and CSS skills.


We welcome all feedback and suggestions - please contact us at to let us know what you think. 


- [Instructor] Follow up components, we've now added three components. The one on line 24 defines the route to the path for the search link. We use the exact attribute here, so this path only matches when there are no other segments in the URL. This route renders the filterable courses table component, when the path and the location path name match. The route on line 24 has a path of slash art, and this will render the Add course form component. When the location path name is slash Add. The return line 35 has no path property. This will render if no other route matches. Inside this, we use react-router-dom to redirect component use like this. It simply forwards the location to the value specified in the two attribute. In this case to slash. You can read more about this component and its options in the React router Dom documentation, you can see that we have surrounded the route components in a switch component. The switch component is very useful, as it ensures that react renders the first route or redirect that matches the location. If we didn't have the switch component around our routes, any route that matched would render. Again, you can read more about the switch components in the documentation. Clicking on each of the route displays the views are specified. clicking Add and search display as we would want. The much more root link as you can see in the code tries to go to a location that we don't have a route for. In this case, the redirect is activated and the user is taken to the slash route and the filterable courses table is rendered. So now we are able to render different views in the app without to make requests for new pages. But there is more we can do with routing, like rendering views with particular data in them depending on what the users click.

About the Author
Ed Wright
Senior Learning Consultant
Learning Paths

Ed is an Outstanding Trainer in Software Development, with a passion for technology and its uses and holding more than 10 years’ experience.

Previous roles have included being a Delivery Manager, Trainer, ICT teacher, and Head of Department. Ed continues to develop existing and new courses, primarily in web design using: PHP, JavaScript, HTML, CSS, SQL, and OOP (Java), Programming Foundations (Python), and DevOps (Git, CI/CD, etc). Ed describes himself as practically minded, a quick learner, and a problem solver who pays great attention to detail. 

Ed’s specialist area is training in Emerging Technologies, within Web Development. Ed mainly delivers courses in JavaScript covering vanilla JS, ES2015+, TypeScript, Angular, and React (the latter is authored by Ed) and has delivered on behalf of Google for PWAs. Ed has also developed a new suite of PHP courses and has extensive experience with HTML/CSS and MySQL. 

Ed is responsible for delivering QA’s Programming Foundations course using the Eclipse IDE. His skillset extends into the DevOps sphere, where he is able to deliver courses based around Agile/Scrum practices, version control, and CI/CD.

Covered Topics