1

I have route configuration with routes from useRoutes() hook which already works properly

<HashRouter>
  {routes}
  <NavigationBar />
</HashRouter>

Now I have to migrate it to new createHashRouter(). The problem is that, docs states that it has to be rendered like

<RouterProvider router={/* return value from createHashRouter */} />

leaving no way to render the <NavigationBar />. Also the RouteProvider doesn't accept any children if I try to render like

<RouterProvider router={/* return value from createHashRouter */} >
  <NavigationBar />
</RouterProvider>

It throws Property 'children' does not exist on type 'IntrinsicAttributes & RouterProviderProps'

Another method

<main>
  <RouterProvider ... />
  <NavigationBar />
</main>

Here NavigationBar doesn't have access to navigation properties like router hooks.

There is no mention in the docs to how to implement the above scenario

Madhan S
  • 683
  • 1
  • 5
  • 16
  • Where do you get this info? Here is shows something very different: https://reactrouter.com/en/main/router-components/hash-router – André Jun 29 '23 at 12:13
  • Here it is for [new method](https://reactrouter.com/en/main/routers/create-hash-router) of creating route r and this is for [migration](https://reactrouter.com/en/main/upgrading/v6-data#but-ive-got-stuff-between-browserrouter-and-routes) – Madhan S Jun 29 '23 at 12:45
  • Then you can follow the method on the link you just mentioned ;). – André Jun 29 '23 at 13:15
  • Yes, but my query is how can I achieve the same using `createHashRouter`. It isn't mentioned in the docs – Madhan S Jun 29 '23 at 13:18
  • It's here: https://reactrouter.com/en/main/routers/create-hash-router – André Jun 29 '23 at 13:22

0 Answers0