feat: shared state mechanisms
This commit is contained in:
1 parent
da4423c141
commit
4a4c7afca7
12 files changed
+279
-120
No files matched your search
@@ -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}")
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user