0

This is the Error I'm getting

//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

1
  • can you remove the {} from your lazy import statement. It should look like this - lazy(()=> import("./pages/aboutus")) Commented Feb 28, 2023 at 10:26

1 Answer 1

1

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"))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.