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

set and setRoutes from within component #18

Open
gausie opened this issue Nov 3, 2015 · 1 comment
Open

set and setRoutes from within component #18

gausie opened this issue Nov 3, 2015 · 1 comment

Comments

@gausie
Copy link
Contributor

gausie commented Nov 3, 2015

It would be great to be able to use setRoutes from within the component (constructor probably). I could then do this:

_getRoutes() {
  return {
    '/': <SomeComponent />,
    '/users/*': <SomeOtherComponent>,
  }
}

constructor() {
  super();
  utils.setRoutes(Object.keys(this._getRoutes()));
}

And then later something like const component = this._getRoutes(this.props.router.src) to choose the component.

However, it seems i can only do it externally to the class. Is this fixable?

@gausie
Copy link
Contributor Author

gausie commented Nov 4, 2015

For the moment, I have done this by adding a static getRoutes function to the class, and then calling utils.setRoutes(Object.keys(App.getRoutes())); at the bottom of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant