How do you define hashbang (#!) fragment routing with react-router-dom v6.9?

385 Views Asked by At

I'm migrating from react-router-dom v5 to v6.9. In the older library you could define hashbang (#!) routes by simply putting it in the basename. Now it looks like we're to use HashRouter, or another option is to add the useHash prop on the BrowserRouter. The problem I'm running into is that the hashtype is assumed to be simply hash (#) and there's no way to define hashbang (#!). Is there any way to define routing with hashbang instead of plain hash?

These use to work in react-router-dom v5:

<BrowserRouter basename="/webresources/test_/search#!">
  <Route path="/search" element={<Search />} />
  <Route path="/configuration" element={<ConfigPage />} />
</BrowserRouter>

or

<HashRouter basename="/webresources/test_/search" hashtype="hashbang">
  <Route path="/search" element={<Search />} />
  <Route path="/configuration" element={<ConfigPage />} />
</HashRouter>

How do you route hashbang routes with react-router-dom v6.9?

0

There are 0 best solutions below