//This is my code where I used the react lazy in React functional component.
import React,{Suspense, lazy} from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Loader from "./components/loader"
const AboutLazy = lazy(()=>{import("./pages/aboutus")})
<BrowserRouter>
<HomeContext.Provider value={{ homes}}>
<Suspense fallback={<Loader />}>
<Routes>
<Route path="/aboutus" element={<AboutLazy />} />
</Routes>
</ Suspense >
</>
</HomeContext.Provider>
</BrowserRouter>
</>
I'm expecting to lazy load the webPage using react lazy
Modify your import command
const AboutLazy = lazy(()=>{import("./pages/aboutus")})
to remove the {}
parenthesis since you are trying to import a component and not return anything
replace with this one:
lazy(()=> import("./pages/aboutus"))