The course is part of this learning path
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.
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
This learning path is aimed at all who wish to learn how to use the ReactJS framework.
We welcome all feedback and suggestions - please contact us at email@example.com 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.
Ed is an Outstanding Trainer in Software Development, with a passion for technology and its uses and holding more than 10 years’ experience.
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.