Skip to main content

consume_context

Function consume_context 

Source
pub fn consume_context<T: 'static + Clone>() -> T
Expand description

Consume context from the current scope, panicking if not found.

Unlike use_context, this is not a hook. It reads the context value directly from the runtime each time it is called, rather than caching it on first render. This means it can be called from anywhere the Dioxus runtime is active — inside event handlers, async tasks, spawned futures, or other non-hook contexts — without following the rules of hooks.