/// A component that conditionally renders children based on the current location.
///
/// # Example
///
///```rust, ignore
/// rsx!(
///     Router {
///         Route { to: "/home", Home {} }
///         Route { to: "/about", About {} }
///         Route { to: "/Blog", Blog {} }
///     }
/// )
/// ```
A component that conditionally renders children based on the current location.
Example


A component that conditionally renders children based on the current location . Example
pub fn Route<'a>(cx: Scope<'a, RouteProps<'a>>) -> Element {
    let router_root = cx
        .use_hook(|_| cx.consume_context::<Arc<RouterCore>>())
        .as_ref()?;
    cx.use_hook(|_| {
        // create a bigger, better, longer route if one above us exists
        let total_route = match cx.consume_context::<RouteContext>() {
            Some(ctx) => ctx.total_route,
            None => cx.props.to.to_string(),
        };
        // provide our route context
        let route_context = cx.provide_context(RouteContext {
            declared_route: cx.props.to.to_string(),
            total_route,
        });
        // submit our rout
        router_root.register_total_route(route_context.total_route, cx.scope_id());
    });
    log::trace!("Checking Route: {:?}", cx.props.to);
    if router_root.should_render(cx.scope_id()) {
        log::trace!("Route should render: {:?}", cx.scope_id());
        cx.render(rsx!(&cx.props.children))
    } else {
        log::trace!("Route should *not* render: {:?}", cx.scope_id());
        None
    }
}
pub fn Route < ' a > ( cx : Scope < ' a , RouteProps < ' a > > ) -> Element { let router_root = cx . use_hook ( | _ | cx . consume_context :: < Arc < RouterCore > > ( ) ) . as_ref ( ) ? ; cx . use_hook ( | _ | { // create a bigger, better, longer route if one above us exists let total_route = match cx . consume_context :: < RouteContext > ( ) { Some ( ctx ) => ctx . total_route , None => cx . props . to . to_string ( ) , } ; // provide our route context let route_context = cx . provide_context ( RouteContext { declared_route : cx . props . to . to_string ( ) , total_route , } ) ; // submit our rout router_root . register_total_route ( route_context . total_route , cx . scope_id ( ) ) ; } ) ; log :: trace ! ( " " cx props to ) ; if router_root . should_render ( cx . scope_id ( ) ) { log :: trace ! ( " " cx scope_id ( ) ) ; cx . render ( rsx ! ( cx props children ) ) } else { log :: trace ! ( " " cx scope_id ( ) ) ; None } }
A component that conditionally renders children based on the current location.
A component that conditionally renders children based on the current location .
cx
Scope<'a, RouteProps<'a>>