import React from 'react' ; import { CurrentRouteContextProvider } from './use_current_route' ; import { RouteMatch } from './types' ; import { useMatchRoutes } from './use_match_routes' ; export function RouteRenderer ( ) { const matches = useMatchRoutes ( ) ; return matches . concat ( ) . reverse ( ) . reduce ( ( prev , match ) => { const { element } = match . route ; return ( < CurrentRouteContextProvider match = { match } element = { prev } > { element } < /CurrentRouteContextProvider>); } , < > < />); }