Я получаю следующее сообщение об ошибке при попытке ленивой загрузки статических маршрутов при использовании React.lazy.Я не уверен, куда идти дальше?
Uncaught Error: Невозможно найти узел на не смонтированном компоненте.
Я предполагаю, что когда я нажимаю дляпуть, чтобы он не был смонтирован?
Это где маршруты определены.В качестве теста я просто загружаю самые тяжелые части приложения.Я использую последнюю версию React и React Router-dom.
const AddressValidator = lazy(() => import('views/AddressValidator/ValidationForm'));
const Landing = lazy(() => import('../views/Dashboard/Landing'));
/**
* Contains routes that will be displayed on the navigation bars
*/
const routes = [
{
path: '/dashboard',
sidebarName: 'Dashboard',
navbarName: 'Dashboard',
component: Landing,
icon: Dashboard,
},
{
path: '/email',
sidebarName: 'Email Templates',
navbarName: 'Email Template Manager',
component: EmailListPage,
icon: Email,
subRoutes: false,
},
{
path: '/email/edit',
navbarName: 'Email Details',
sidebarName: 'Edit',
component: EmailDetailsPage,
hidden: true,
},
{
path: '/address',
sidebarName: 'Address Validation',
navbarName: 'Address Validation',
component: AddressValidator,
icon: Shipping,
},
{
path: '/mta',
sidebarName: 'MyTech Assistant',
navbarName: 'MyTech Assistant',
icon: Book,
subRoutes: mtaRoutes,
showLanding: false,
},
{
path: '/lmi',
sidebarName: 'Log Me In',
navbarName: 'LMI Agent Account Creation',
component: UserCreator,
icon: VerifiedUser,
},
{
path: '/user_management',
sidebarName: 'User Management',
navbarName: 'User Management',
component: UserManagement,
icon: People,
},
{
path: '/user_restriction',
sidebarName: 'User Restriction',
navbarName: 'User Restriction',
component: UserRestriction,
icon: Lock,
},
{
path: '/mobile_catalog',
sidebarName: 'Mobile Catalog',
navbarName: 'Mobile Catalog',
component: MobileCatalogExplorer,
icon: '',
},
];
Вот файл app.js
const hist = createBrowserHistory();
const App = () => (
<Provider store={createStore(reducers)}>
<MsalAuthProvider>
<ModalRoot />
<AlertRoot />
<Suspense fallback={<div>Loading...</div>}>
<Router history={hist}>
<Switch>
{ indexRoutes.map((prop, key) => <ProtectedRoute path={prop.path} component={prop.component} key={key} />)}
</Switch>
</Router>
</Suspense>
</MsalAuthProvider>
</Provider>
);