mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add react-router
This commit is contained in:
parent
6534c0a596
commit
b2372a96e2
16 changed files with 176 additions and 59 deletions
22
src/components/HistoryRouter.tsx
Normal file
22
src/components/HistoryRouter.tsx
Normal file
|
@ -0,0 +1,22 @@
|
|||
import React, { useLayoutEffect } from 'react';
|
||||
import { HistoryRouterProps, Router } from 'react-router-dom';
|
||||
|
||||
export function HistoryRouter({ basename, children, history }: HistoryRouterProps) {
|
||||
const [state, setState] = React.useState({
|
||||
action: history.action,
|
||||
location: history.location
|
||||
});
|
||||
|
||||
useLayoutEffect(() => history.listen(setState), [history]);
|
||||
|
||||
return (
|
||||
<Router
|
||||
basename={basename}
|
||||
// eslint-disable-next-line react/no-children-prop
|
||||
children={children}
|
||||
location={state.location}
|
||||
navigationType={state.action}
|
||||
navigator={history}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue