0

So pretty basic stuff, I have a link in guest component to teads to a Home compoent, the problem is that I cant see the whole Guest Component, the loading only happens when I mannualy type the Home PATH.

import React,{Suspense} from 'react'
import {
  BrowserRouter as Router,
  Switch,
  Route,
} from "react-router-dom";
import GuestPage from './GuestPage';

const Home= React.lazy(
  () =>
    new Promise((resolve, reject) =>
      setTimeout(() => resolve(import("./Home")), 3000)
    )
);

function App() {
  return (
    <div>
      <Router> 
      <Switch>
          <Suspense fallback={<div>loading</div>}>
            <Route path = '/Home' component={Home}/>          
          </Suspense>   
              <Route path = '/' component={GuestPage}/> 
              
      </Switch>
      </Router>
    </div>
  );
}

export default App;
Tequila
  • 246
  • 1
  • 13
  • 1
    Does this answer your question? [Components After React Suspense Not Loading?](https://stackoverflow.com/questions/60647660/components-after-react-suspense-not-loading) - Move all of the routes inside the Suspense. Be sure to also add `exact` to the GuestPage path or it will also render for all pages - since all URLs include `/`. – cbr Jun 04 '21 at 13:50
  • apprciate the help – Tequila Jun 04 '21 at 13:55

0 Answers0