I suddenly get this error and not sure why.I did not change the "react-router-dom": "^6.0.0-beta.4"
version. But the "react-dom": "^16.8.4"
” had changed to "react-dom": "^16.13.1"
,
Dunno if that had anything to do with I don’t know but the useRoutes
comes from "react-router-dom"
and that’s where the error originate ya.
Anyone have a clue?
Here is my App.jsx where i use the useRoutes(routes)
and it’s giving me the error:
JavaScript
x
54
54
1
import React, { useEffect } from 'react';
2
import { AnimatePresence } from 'framer-motion';
3
import { connect } from 'react-redux';
4
import { compose } from 'recompose';
5
import { useRoutes } from 'react-router-dom';
6
import { ThemeContextProvider } from './theme/ThemeProvider';
7
import { getAlbumData } from './redux/albumData/albumData.actions';
8
import { getMetaData } from './redux/albumMetaData/albumMetaData.actions';
9
import {
10
startTagsListener,
11
startTagsCategoryListener,
12
} from './redux/global/global.actions';1111
13
14
import { withAuthentication } from './session';
15
import './styles/index.css';
16
import routes from './routes';
17
18
require('react-dom');
19
20
const AnimatedSwitch = () => {
21
const routing = useRoutes(routes);
22
23
return (
24
<AnimatePresence exitBeforeEnter initial={false}>
25
<div>{routing}</div>
26
</AnimatePresence>
27
);
28
};
29
30
const App = props => {
31
const { getMeta, getAlbum, startTagListener, startTagCategoryListener } = props;
32
33
useEffect(() => {
34
getMeta();
35
getAlbum();
36
startTagListener();
37
startTagCategoryListener();
38
}, [getMeta, getAlbum, startTagListener, startTagCategoryListener]);
39
40
return (
41
<ThemeContextProvider>
42
{AnimatedSwitch()}
43
</ThemeContextProvider>
44
);
45
};
46
const mapDispatchToProps = dispatch => ({
47
getMeta: () => dispatch(getMetaData()),
48
getAlbum: () => dispatch(getAlbumData()),
49
startTagListener: () => dispatch(startTagsListener()),
50
startTagCategoryListener: () => dispatch(startTagsCategoryListener()),
51
});
52
53
export default compose(connect(null, mapDispatchToProps), withAuthentication)(App);
54
Here are the routes and I have not changed them in the last month:
JavaScript
1
44
44
1
import React from 'react';
2
import ContentLayout from './components/structure/ContentLayout';
3
import DashboardLayout from './components/DashboardLayout';
4
import AccountView from './components/DashboardLayout/views/account/AccountView';
5
import SearchListView from './components/DashboardLayout/views/search/SearchListView';
6
import DashboardView from './components/DashboardLayout/views/dashboard/DashboardView';
7
import NotFoundView from './components/DashboardLayout/views/errors/NotFoundView';
8
import CreateContentView from './components/DashboardLayout/views/creator/CreateContentView';
9
import SettingsView from './components/DashboardLayout/views/settings/SettingsView';
10
import LoginView from './components/DashboardLayout/views/auth/LoginView';
11
import RegisterView from './components/DashboardLayout/views/auth/RegisterView';
12
import SubmissionsView from './components/DashboardLayout/views/submissions/SubmissionsView';
13
import InboxView from './components/DashboardLayout/views/inbox/InboxView';
14
15
const routes = [
16
{
17
path: 'app',
18
element: <DashboardLayout />,
19
children: [
20
{ path: 'account', element: <AccountView /> },
21
{ path: 'search', element: <SearchListView /> },
22
{ path: 'dashboard', element: <DashboardView /> },
23
{ path: 'create', element: <CreateContentView /> },
24
{ path: 'submissions', element: <SubmissionsView /> },
25
{ path: 'inbox', element: <InboxView /> },
26
{ path: 'settings', element: <SettingsView /> },
27
{ path: 'login', element: <LoginView /> },
28
{ path: 'register', element: <RegisterView /> },
29
{ path: '*', element: <NotFoundView /> },
30
{ path: '/', element: <DashboardView /> },
31
],
32
},
33
{
34
path: '/',
35
element: <ContentLayout />,
36
children: [
37
{ path: '404', element: <NotFoundView /> },
38
{ path: '*', element: <NotFoundView /> },
39
],
40
},
41
];
42
43
export default routes;
44
Advertisement
Answer
I have seen the error message and it clearly explains that path “/” should not be given under route “app”.So try changing the path to some other valid name or remove it.