shared state build error #1373
testforvln
started this conversation in
General
Replies: 1 comment 1 reply
-
You need to clone the use_shared state before moving it into a future. let state = use_shared_state(cx, || false);
cx.spawn({
to_owned![state];
async move {
// use state in the future now that it has been cloned and moved
}
}) (Converting this to a discussion because it seems more like a help question than issue/feature request with Dioxus) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
When using shared state, the hello-dioxus project failed compiling.
Steps To Reproduce
Steps to reproduce the behavior:
hello-dioxus.zip
Expected behavior
error[E0521]: borrowed data escapes outside of function
Screenshots
Error like below:
|
52 | #[inline_props]
| --------------- lifetime
'a
defined here53 | fn NavBar(cx: Scope) -> Element {
| --
cx
is a reference that is only valid in the function body54 | let is_logged_in = use_shared_state::(cx).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
|
cx
escapes the function body here| argument requires that
'a
must outlive'static
For more information about this error, try
rustc --explain E0521
.Environment:
web
]Beta Was this translation helpful? Give feedback.
All reactions