Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't require a root route #33

Closed
ryanflorence opened this issue Jun 19, 2014 · 1 comment
Closed

don't require a root route #33

ryanflorence opened this issue Jun 19, 2014 · 1 comment
Labels

Comments

@ryanflorence
Copy link
Member

Currently you must require a root route, the following doesn't do anything:

Router(
  Route({name: 'foo', handler: Foo}),
  Route({name: 'bar', handler: Bar})
);

You have to do this:

Router(
  Route({handler: App},
    Route({name: 'foo', handler: Foo}),
    Route({name: 'bar', handler: Bar})
  )
);

Maybe we can detect that routes.length > 1 and then provide a default route and handler like:

React.createClass({
  render: function() {
    return <div>{this.props.activeRoute}</div>
  }
});

Even though I suspect every real app out there will have a root route (shared layout, global nav, etc), when you're just getting started this is a hurdle that isn't obvious and it would be nice to feel productive the first time you use this router.

@mjackson
Copy link
Member

Since the Router API is deprecated and going away, I don't believe this is an issue any more. Routes are now simply a variable assignment, which can't be assigned to two things at once.

var routes = (
  <Route handler={App}>
    <Route name="user" handler={User}/>
  </Route>
);

React.renderComponent(routes, document.body);

@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants