freya_router::prelude

Function use_outlet_context

Source
pub fn use_outlet_context<R: Clone + 'static>() -> OutletContext<R>
Expand description

Returns the current outlet context from the component hierarchy.

This hook retrieves the outlet context from the current component scope. If no context is found, it creates a new context with a default level of 0.

§Type Parameters

  • R - The routable type that implements the routing logic

§Returns

Returns an OutletContext<R> containing the current nesting level information.

§Examples

let outlet_ctx = use_outlet_context::<MyRouter>();
println!("Current nesting level: {}", outlet_ctx.level());