Removes the Router/Switch/Route/Link/LinkContainer legacy-context
warnings. Keeps the shared history singleton (used outside React by
NotificationsObserver + Utils/location) via unstable_HistoryRouter, and
bridges v6 hooks back to v4-shaped history/match/location props with a
new withRouterCompat HOC so the ~20 class pages stay untouched.
- <Switch> -> <Routes>, component= -> element=
- Authenticated/Public -> guard components (children or <Navigate replace>)
- LocationListener -> useLocation + useEffect function
- regex route /fire/:type(active|archive|alert)/:id -> /fire/:type/:id
- history.listen callback is ({ location }) in history v5
Browser-verified: SPA nav, /subscriptions->/login auth redirect,
deep-link /fire/archive/:id (params), browser back/forward. REST smoke
byte-identical.
8 lines
340 B
JavaScript
8 lines
340 B
JavaScript
import { createBrowserHistory } from 'history';
|
|
|
|
// Shared history singleton. It backs react-router's <HistoryRouter> (App.js)
|
|
// AND is used outside the React tree (NotificationsObserver push, Utils/location
|
|
// listen), so it must be the same instance the router navigates.
|
|
const history = createBrowserHistory();
|
|
|
|
export default history;
|