export default function match (routes, component) { let matchers; if (Array.isArray(routes)) { matchers = routes.map(routeParser) } else { matchers = [routeParser(routes)] } const routeComponent = (props, context) => { const matcher = matchers.find((matcher) => matcher.match(context.route)) if (matcher) { // match contains params return React.cloneElement(component, matcher.match(context.route)) } return null } routeComponent.contextTypes = { route: React.PropTypes.string } return React.createElement(routeComponent) }
let routes = routing.map(function(r){ r.route = Route(r.url) return r }),