fermi 0.4.3

Global state management for Dioxus
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::rc::Rc;

use crate::AtomRoot;
use dioxus_core::ScopeState;

// Returns the atom root, initiaizing it at the root of the app if it does not exist.
pub fn use_atom_root(cx: &ScopeState) -> &Rc<AtomRoot> {
    cx.use_hook(|| match cx.consume_context::<Rc<AtomRoot>>() {
        Some(root) => root,
        None => panic!("No atom root found in context. Did you forget to call use_init_atom_root at the top of your app?"),
    })
}