feat: add some helpers to use_ref

This commit is contained in:
Jonathan Kelley committed 2022-02-19 18:00:03 -05:00
1 parent 93b4f745af
commit 45473ece8c
2 files changed
+32

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
use std::collections::HashMap;
use dioxus::prelude::*;
fn main() {}
fn app(cx: Scope) -> Element {
let val = use_ref(&cx, || HashMap::<u32, String>::new());
// Pull the value out locally
let p = val.read();
// to get an &HashMap we have to "reborrow" through the RefCell
// Be careful: passing this into children might cause a double borrow of the RefCell and a panic
let g = &*p;
cx.render(rsx! {
div {
"hi"
}
})
}