1

i am getting below error [PublicRoute] is not a component. All component children of must be a or <React.Fragment> my code is like this PublicRoute.js is

    import React from "react";
import { Route } from "react-router";

export default function PublicRoute(props) {
  return <Route {...props} />;
}

App.js is

>  import "./App.css"; import Navbar from "./components/common/Navbar";
> import { Routes } from "react-router"; import PublicRoute from
> "./components/common/PublicRoute"; import Home from
> "./components/Home";
> 
> function App() {   return (
>     <div>
>       <Navbar />
>       <Routes>
>         <PublicRoute path="/" element={<Home />} exact />
>       </Routes>
>     </div>   ); }
> 
> export default App;

How can i solve above issue ? For ref please find the attached image enter image description here

somutesting
  • 289
  • 1
  • 5
  • 17
  • 1
    Check this: https://stackoverflow.com/questions/70171991/navigate-is-not-a-route-component-all-component-children-of-routes-must-be/70172518 – davood Sandoghsaz Dec 09 '21 at 05:40
  • 1
    Under , you have provided and in that rendering Home as an element. So that's wrong. The correct way to do define your route is: `} />` – Surjeet Bhadauriya Dec 09 '21 at 05:42

0 Answers0