I found a similar SO Post and this unanswered post, however, what do you do when you need a dynamic path (path parameter)?
Like /calendar/:year/:month/:day/event
where it could be, for example, /calendar/11/4/21/event
I found a similar SO Post and this unanswered post, however, what do you do when you need a dynamic path (path parameter)?
Like /calendar/:year/:month/:day/event
where it could be, for example, /calendar/11/4/21/event
The basename
that you can pass to a router (e.g. <BrowserRouter basename='/thing'>
) is not dynamic. You should think of the basename as the static path to the root directory where your app is located (although this might not be a literal path since you're most likely using a dynamic server).
Occasionally I have seen requests for dynamic basenames, usually when someone has language sections of their site (example.com/en/about
and example.com/zh/about
). The usual reason for wanting to include this information in the basename
is so that it doesn't have to be included in URIs. However, the basename
isn't supposed to contain information about the route; any data that isn't going to be the same for every single route in your application should not be part of the basename.