Using link components

In this section, we'll look at creating links. You might be tempted to use the standard <a> elements to link to pages controlled by react-router. The problem with this approach is that these links will try to locate the page on the backend by sending a GET request. This isn't what we want to happen, because the route configuration is already in the browser.

We'll start with a very simple example that illustrates how <Link> elements are just like <a> elements in most ways. Then, you'll see how to build links that use URL parameters and query parameters.

Basic linking

The idea of a link is pretty simple. We use it to point to routes, which subsequently render new content. However, the Link component also takes care of the browser ...

Get React and React Native now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.