Skip to content

Commit

Permalink
fix: router
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Dec 11, 2024
1 parent 0b2cbfc commit 07d18fd
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,6 @@ const App = <A extends Action = Action, S = unknown>({
maxTotalSeconds = 60 * 60,
...routesProps
}: AppProps<A, S>): JSX.Element => {
let router: ReactNode
if (SSR) {
if (!path) throw new Error("Running server and path not provided.")

router = (
<StaticRouter location={path}>
<Routes path={path} {...routesProps} />
</StaticRouter>
)
} else {
router = (
<BrowserRouter>
<BrowserRoutes {...routesProps} />
</BrowserRouter>
)
}

// TODO: cannot use document during SSR
// const root = document.getElementById("root") as HTMLElement

Expand Down Expand Up @@ -115,7 +98,15 @@ const App = <A extends Action = Action, S = unknown>({
setTotalSeconds(maxTotalSeconds)
}}
/> */}
{router}
{SSR ? (
<StaticRouter location={path as string}>
<Routes path={path as string} {...routesProps} />
</StaticRouter>
) : (
<BrowserRouter>
<BrowserRoutes {...routesProps} />
</BrowserRouter>
)}
</Provider>
</ThemeProvider>
)
Expand Down

0 comments on commit 07d18fd

Please sign in to comment.