If you've ever worked with routing outside of React, you probably already know that it can get messy quickly. With react-router
, it's much easier to collocate routes with the content that they render. In this section, you'll see that this is due in large part to the declarative JSX syntax used to define routes.
We'll create a basic hello world example route so that you can get a basic handle on what routes look like in React applications. Then, we'll look at how you can organize your route declarations by feature instead of in a monolithic module. Finally, you'll implement a common parent-child routing pattern.
Let's create a simple route that renders a simple component. First, we have the simplest possible React component that we want to render when the route is activated:
import React from 'react'; export default () => ( <p>Hello Route!</p> );
Next, let's look at the route definition itself:
import React from 'react...