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.
- Now that we have the navigation links in the app, we want the views to actually change when we click on them. But that's the job with the route component. The route component is from the react query to DM library. It's used to define which component tree should be rendered when a particular location matches the route path. This component is one of the most important to understand, if you want to add route into your app. It can receive some props when it's used. These are paths, a render method, and some other options. The path isn't anything more than the part of the URL we want this route to work with. Usually, you'll define a route component for every two attribute you're using your application. The path is defined as a string or an array of strings. The easiest and recommended way to render from a route is to our child components to it. However, there are three other ways to render from a root. These are considered legacy, as they were the way to render on routes before Hawks were introduced. You can supply a component's tribute with the name of the component to rendering curly braces. You can use the render attribute. This requires a call back the return to component, or you can use the children attribute, which is useful in animations. As you can render on this route, whether the path matches the location or not. The options that can be supplied, make the route more specific. Using exact means that the root will only match, if the path supplied matches location, pathname exactly. Adding strict means that paths where the trends slash included will only match a location's pathname that has a trailing slash. Strict has no effect, if there are additional URL segments in the location's pathname. Supplying a location prop needs it's value to be an object. When matching a root, it uses the current history location and the paths supplied. The location prop allows for a location with a different pathname to be matched. As with the children render method, this is useful in animations. The final option in the API for route is sensitive. When used, it defines that the path and the location pathname must be a case match as well.
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.