Exploring React Router and other useful packages
So far, you have only created a couple of single-page apps, but you haven’t touched some advanced functionalities. However, single-page apps are not limited to a single URL. For example, if you navigate to your Gmail account, you will see that the URL changes with every action that you might take.
While there are several solutions that enable you to achieve routing in SPAs, React Router is the standard solution, and it is a well-tested, mature package.
The underlying idea of a frontend page router is that it should enable rendering different components on the same page depending on the route that is loaded. For instance, the /about
route would cause the app to load a component called About.jsx
in the main App
component, removing other previously loaded components. The package provides a basic structure, within the BrowserRouter
class, which can be used to wrap an entire root App
component.
React is such a popular framework...