Function dioxus::prelude::use_context[][src]

pub fn use_context<T>(cx: &'a ScopeState) -> Option<UseSharedState<'a, T>> where
    T: 'static, 
Expand description

This hook provides some relatively light ergonomics around shared state.

It is not a substitute for a proper state management system, but it is capable enough to provide use_state - type ergonimics in a pinch, with zero cost.

Example

Provider


Consumer


How it works

Any time a component calls write, every consumer of the state will be notified - excluding the provider.

Right now, there is not a distinction between read-only and write-only, so every consumer will be notified.