feat: shared state mechanisms
This commit is contained in:
1 parent
da4423c141
commit
4a4c7afca7
12 files changed
+279
-120
No files matched your search
@@ -45,13 +45,10 @@ fn html_and_rsx_generate_the_same_output() {
|
||||
|
||||
assert_eq!(
|
||||
change.edits,
|
||||
[
|
||||
PushRoot { root: 1 },
|
||||
SetText {
|
||||
text: "Goodbye world"
|
||||
},
|
||||
PopRoot
|
||||
]
|
||||
[SetText {
|
||||
text: "Goodbye world",
|
||||
root: 1
|
||||
},]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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