I have started going over how to use React with react-router-dom, and I am interested in understanding the reason for the Route component matching any path.
For example:
Well an example might be if you have a blog and you have a route like /posts and then another route that might be /posts/:postId and you have some posts displayed and maybe somewhere beneath them a full post, a specific one. Might be more cases but ye mostly it s not used like this I guess.
One important thing to note is that a <Route path> matches the beginning of the URL, not the whole thing. So a <Route path="/"> will always match the URL. Because of this, we typically put this <Route> last in our <Switch>. Another possible solution is to use <Route exact path="/"> which does match the entire URL.