Mohamed Atef
6 Aug 2022
React js
Hello everyone I am getting this error in my Reactjs application
React.Fragment. React.Fragment can only have key props and children
My code is
export const renderRoutes = (routes = []) => (
<Suspense fallback={<LoadingScreen />}>
<Switch>
{routes.map((route, i) => {
const Guard = route.guard || Fragment;
const Layout = route.layout || Fragment;
const Component = route.component;
return (
<Route
key={i}
path={route.path}
exact={route.exact}
render={(props) => (
<Guard DeepLink={props.pathname}>
<Layout>
{route.routes
? renderRoutes(route.routes)
: <Component {...props} />}
</Layout>
</Guard>
)}
/>
);
})}
</Switch>
</Suspense>
);
const routes = [
{
exact: true,
guard: GuestGuard,
path: '/404',
component: lazy(() => import('src/views/errors/NotFoundView'))
},
]
How can I solve this issue?
Jo Micheal
6 Aug 2022
Best Answer
Fragment cannot have any props the only way to pass to the Fragment is the children (Components).
If you removed the DeepLink prop it will work fine.
© 2024 Copyrights reserved for web-brackets.com