React-router: IndexRoute vs DefaultRoute

I am wondering what is the difference between IndexRouteand DefaultRoutein the example below? As I understand it, in both cases it will be displayed Home, right?

<Route path="/" handler={App}>
  <IndexRoute handler={Home}/>
  <Route path="about" handler={About}/>
</Route>

and

<Route path="/" handler={App}>
  <DefaultRoute handler={Home}/>
  <Route path="about" handler={About}/>
</Route>
+4
source share
1 answer

DefaultRoutemissing as response-router v1.0. Instead, it is introduced IndexRoute.

From the docs:

// v0.13.x
// with this route config
<Route path="/" handler={App}>
  <DefaultRoute name="home" handler={Home}/>
  <Route name="about" handler={About}/>
</Route>

// v1.0
<Route path="/" component={App}>
  <IndexRoute component={Home}/>
  <Route path="about" component={About}/>
</Route>

See the upgrade guide for details .

+8
source

Source: https://habr.com/ru/post/1609164/


All Articles