Closed gyuhyeon closed 5 years ago
The basename
prop is meant to emulate the <base>
tag, of which, there can only be one on a page at a time.
What you're looking for here is a top level BrowserRouter to drive the interaction with the DOM history, and many MemoryRouters underneath that to handle several sections of your application.
Version
5.0.0
Test Case
https://codesandbox.io/s/3v04q4prrq
Steps to reproduce
Have multiple
Routers
defined in order to utilize basenames. There are cases when this is required especially in enterprise level setups, where multiple different servers reverse proxy onto a single frontend react dedicated server with different unique routes as :/finance/mobile/web
,/order/mobile/web
,/point/web
. It's not exactly fun to append all those routes on to the routing config if there are 400+ unique urls.Expected Behavior
/foo/about
should render a single About component only./foo/asdf/
shouldn't render anything(0 components)./bar/about
should render a single About component only./bar/asdf
should render a single NotFound component only.Actual Behavior
/foo/about
renders the About component and also other components randomly(/bar/about
,/bar/notfound
) along with it below./foo/asdf
also seemingly renders other components randomly./bar/about
renders a single About component only as expected./bar/asdf
renders a single NotFound component only as expected.Last words
Thank you.