From Static to Dynamic Routes
Thus far, all examples have had two routes: /
for the Dashboard
component and /orders
for the Orders
component. But you can, of course, add as many routes as needed. If your website consists of 20 different pages, you can (and should) add 20 route definitions (i.e., 20 Route
components) to your App
component.
On most websites, however, you will also have some routes that can't be defined manually—because not all routes are known in advance.
Consider the example from before, enriched with additional components and some realistic dummy data:
Note
You can find the code for this example on GitHub at https://packt.link/KcDA6. In the code, you'll notice that many new components and style files were added. The code does not use any new features, though. It's just used to display a more realistic user interface and output some dummy data.
In the preceding screenshot,...