Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Why my router is not lazy importing component ReactJS?

I using react-router-dom but its not importing my component lazily. I dont know what is wrong. I dont have any error or warning. Its just not showing my component. For make it more clear my sandbox : https://codesandbox.io/s/cold-thunder-kz7sy?file=/src/App.js

If you dont have time for check sandbox my codes :

AppViews

export const AppViews = () => {
  

  return (
    <Suspense fallback={<p>Loading..</p>}>
      <Switch>
        <Route
          exact
          path={`${APP_PREFIX_PATH}/dashboard`}
          component={lazy(() => import(`./dashboard`))}
        />

        <Route
          exact
          path={`${APP_PREFIX_PATH}/commons`}
          component={lazy(() => import(`./commons`))} 
        />

        <Redirect
          exact
          from={`${APP_PREFIX_PATH}`}
          to={`${APP_PREFIX_PATH}/commons`}
        />
      </Switch>
    </Suspense>
  );
};

export default AppViews;

Commons

const Commons = ({ match }) => {
  return (
    <Suspense fallback={<Loading cover="content" />}>
      <Router>
        <Switch>
          <Route
            exact
            path={`${match.url}/documents`}
            component={lazy(() => import(`./documents`))}
          />
        </Switch>
      </Router>

      <Redirect from={`${match.url}`} to={`${match.url}/documents`} />
    </Suspense>
  );
};

export default Commons;

After that my url is turning localhost:3000/v1/commons/documents but my Documents component doesn't import. My screen shows nothing. What is wrong in that codes ? I tried to delete exacts and tried again but still same. Thanks for reply!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!