Home > Software engineering >  loading experience for IndexRedirect react router
loading experience for IndexRedirect react router

Time:09-14

I'm wondering how the loading experience is for the IndexRedirect. In this example:

<Route path="/" component={App}>
  <IndexRedirect to="/welcome" />
  <Route path="welcome" component={Welcome} />
  <Route path="about" component={About} />
</Route>

Does it load the App component first and then redirect to the welcome path or how does it work?

CodePudding user response:

Does it load the App component first and then redirect to the welcome path or how does it work?

Actually, just took a look at the docs you linked and I'd agree with your assessment. The App component would be mounted and then its React subtree, i.e. its children prop, would be rendered. The IndexRedirect is the default route/redirect component so the app would be redirected to "/welcome" and then mount & render the Welcome component (and its React subtree).

  • Related