Rename modules to use snake_case (#1498)

This commit is contained in:
Leonard authored and GitHub committed 2023-09-26 17:20:29 -05:00
1 parent 31780b3ede
commit a2dd926f7f
13 files changed
+18 -18

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
use dioxus_core::ScopeState;
/// Consume some context in the tree, providing a sharable handle to the value
///
/// Does not regenerate the value if the value is changed at the parent.
pub fn use_context<T: 'static + Clone>(cx: &ScopeState) -> Option<&T> {
cx.use_hook(|| cx.consume_context::<T>()).as_ref()
}
/// Provide some context via the tree and return a reference to it
///
/// Once the context has been provided, it is immutable. Mutations should be done via interior mutability.
pub fn use_context_provider<T: 'static + Clone>(cx: &ScopeState, f: impl FnOnce() -> T) -> &T {
cx.use_hook(|| {
let val = f();
cx.provide_context(val.clone());
val
})
}