render( props, state ) { if ( !state.current ) { return <div id="content" />; } return cloneElement(state.current, {...props, "params": state.params}); }
// Iterate through all routes and flatten them flattenRoutes( children, parent, reset ) { for ( let i in children ) { let child = children[i]; if ( child.nodeName !== Route ) { continue; } let node = child; if ( parent ) { node = parent; } let props = { ...node.attributes, ...child.attributes }; if ( props.static && parent && parent.attributes.path && child.attributes.path ) { props.path = parent.attributes.path + child.attributes.path; } if ( props.default && props.static && props.path ) { props.path = ["/", ...props.path]; } child = cloneElement(child, props); this.state.routes.push(child); if ( child.children.length > 0 ) { this.flattenRoutes(child.children, child); } } }