fix(router): Expose the react router from the worklist too. (#5062)
This commit is contained in:
1 parent
c2cc0832f3
commit
14f5f0c074
12 files changed
+101
-95
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import { useParams, useLocation, useNavigate } from 'react-router';
|
||||
import { useParams, useLocation } from 'react-router';
|
||||
import PropTypes from 'prop-types';
|
||||
import { utils } from '@ohif/core';
|
||||
import { ImageViewerProvider, DragAndDropProvider } from '@ohif/ui-next';
|
||||
@@ -7,7 +7,6 @@ import { useSearchParams } from '../../hooks';
|
||||
import { useAppConfig } from '@state';
|
||||
import ViewportGrid from '@components/ViewportGrid';
|
||||
import Compose from './Compose';
|
||||
import { history } from '../../utils/history';
|
||||
import loadModules from '../../pluginImports';
|
||||
import { defaultRouteInit } from './defaultRouteInit';
|
||||
import { updateAuthServiceAndCleanUrl } from './updateAuthServiceAndCleanUrl';
|
||||
@@ -52,9 +51,6 @@ export default function ModeRoute({
|
||||
const locationRef = useRef(null);
|
||||
const isMounted = useRef(false);
|
||||
|
||||
// Expose the react router dom navigation.
|
||||
history.navigate = useNavigate();
|
||||
|
||||
if (location !== locationRef.current) {
|
||||
layoutTemplateData.current = null;
|
||||
locationRef.current = location;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Routes, Route, Link } from 'react-router-dom';
|
||||
import { Routes, Route, Link, useNavigate } from 'react-router-dom';
|
||||
import { ErrorBoundary } from '@ohif/ui-next';
|
||||
|
||||
// Route Components
|
||||
@@ -11,8 +11,9 @@ import NotFound from './NotFound';
|
||||
import buildModeRoutes from './buildModeRoutes';
|
||||
import PrivateRoute from './PrivateRoute';
|
||||
import PropTypes from 'prop-types';
|
||||
import { routerBase, routerBasename } from '../utils/publicUrl';
|
||||
import { routerBasename } from '../utils/publicUrl';
|
||||
import { useAppConfig } from '@state';
|
||||
import { history } from '../utils/history';
|
||||
|
||||
const NotFoundServer = ({
|
||||
message = 'Unable to query for studies at this time. Check your data source configuration or network connection',
|
||||
@@ -127,6 +128,8 @@ const createRoutes = ({
|
||||
];
|
||||
|
||||
function RouteWithErrorBoundary({ route, ...rest }) {
|
||||
history.navigate = useNavigate();
|
||||
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
return (
|
||||
<ErrorBoundary context={`Route ${route.path}`}>
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import { NavigateFunction } from 'react-router';
|
||||
|
||||
type History = {
|
||||
interface History {
|
||||
navigate: NavigateFunction;
|
||||
};
|
||||
}
|
||||
|
||||
let navigate;
|
||||
|
||||
export const history: History = {
|
||||
navigate: null,
|
||||
set navigate(nav: NavigateFunction) {
|
||||
navigate ??= nav;
|
||||
},
|
||||
get navigate() {
|
||||
return navigate;
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user