feat: shared state mechanisms

This commit is contained in:
Jonathan Kelley committed 2021-10-11 15:35:20 -04:00
1 parent da4423c141
commit 4a4c7afca7
12 files changed
+279 -120

No files matched your search

+2 -2
View File
@@ -18,12 +18,12 @@ fn shared_state_test() {
struct MySharedState(&'static str);
static App: FC<()> = |cx, props| {
cx.use_provide_state(|| MySharedState("world!"));
cx.provide_state(MySharedState("world!"));
rsx!(cx, Child {})
};
static Child: FC<()> = |cx, props| {
let shared = cx.use_consume_state::<MySharedState>()?;
let shared = cx.consume_state::<MySharedState>()?;
rsx!(cx, "Hello, {shared.0}")
};