Opt out of React-Router v4
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')
}
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:
- Continue to not support other routers or react-native
- Load all router imports through
mirrorx/router, a submodule. Then dynamically import it unless an option ofnoRouteris specified. - Create a separate
mirrorx-routerpackage, which can be configured and setup
Both 2 & 3 would create breaking changes, though easy to fix.
I would recommend mirrorx/router as a submodule, what's your opinion?
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.