Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-router: IndexRoute vs DefaultRoute

I'm wondering what's the difference between IndexRoute and DefaultRoute in example below? As I understand in both cases Home will be rendered, 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>
like image 886
VB_ Avatar asked Feb 09 '23 23:02

VB_


1 Answers

DefaultRoute is gone as of react-router v1.0. IndexRoute is introduced instead.

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>

More in the upgrade guide.

like image 159
Jan Klimo Avatar answered Feb 11 '23 16:02

Jan Klimo