Remove match() calls from RoutingEnvironmentMixin or simplify match
I'd love to find a way to get these out of there. Ideally, you should be able to create a custom router like this:
React.createClass({
mixins: [RoutingEnvironmentMixin],
render: function() {
if (this.getPath() === '/whatever') {
return MyComponent();
}
return SomeOtherComponent();
}
});
or to compose two (controlled) routers like this:
React.createClass({
mixins: [RoutingEnvironmentMixin],
render: function() {
return div(null,
SubRouterOne({path: this.getPath()}),
SubRouterTwo({path: this.getOtherPath()})
);
}
});
(Currently, neither of these will work because match() must be implemented.)
In other words, RoutingEnvironmentMixin gets you the path and custom routers can decide what to do with it.
The current impediments to this are getPrefix, getPath, and the onBeforeNavigation handler (the latter of which adds the match to the navigation object so that navigations that can't be handled can be cancelled, e.g. by CaptureClicks).
Honestly, I'm not sure if it's going to be possible to get rid of the match calls; it's not an unrealistic requirement that routers be capable of telling you whether they can route a provided path. If that's the case, we should probably consider what the minimal requirements of that interface are (e.g. must it expose route, unmatchedPath, etc.? Do they always make sense?) and solidify that.