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

Opt out of React-Router v4 #51

Open
ShMcK opened this issue Sep 10, 2017 · 3 comments
Open

Opt out of React-Router v4 #51

ShMcK opened this issue Sep 10, 2017 · 3 comments

Comments

@ShMcK
Copy link
Contributor

ShMcK commented Sep 10, 2017

There should be a way to opt out of using react-router v4.

This would be especially useful for mobile. Currently, Mirror is not compatible with "react-native" due to the dependency on react-dom. Opting into react-router-native isn't much better, as it's not currently the most popular routing option.

As a suggestion, using dynamic imports, would make it possible to opt out of using the router.

// default to true
options.useRouter = options.useRouter || true

if (options.useRouter) {
  // dynamic import (may require Webpack plugin)
  import('./router')
}
@ShMcK ShMcK changed the title Mirror Opt out of Router Opt out of React-Router v4 Sep 10, 2017
@ShMcK
Copy link
Contributor Author

ShMcK commented Sep 12, 2017

I've done some experimenting with opting out of React Router in Mirror on this project branch. It's not complete, and may not be necessary.

I see a few options now for dealing with the router:

  1. Continue to not support other routers or react-native
  2. Load all router imports through mirrorx/router, a submodule. Then dynamically import it unless an option of noRouter is specified.
  3. Create a separate mirrorx-router package, which can be configured and setup

Both 2 & 3 would create breaking changes, though easy to fix.

@llh911001
Copy link
Member

I would recommend mirrorx/router as a submodule, what's your opinion?

@ShMcK
Copy link
Contributor Author

ShMcK commented Sep 12, 2017

I think think a submodule makes the most sense.

Also the same design of dva/router.

Dva also recently created multiple different router packages with the 2.0.1 release, including "dva/no-router". I think this is a bit much, as its not really necessary to load another package if you're not using the router.

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

2 participants