Closed Dimchikkk closed 2 months ago
I'm able to reproduce your crash, but only on the second modification reload. I'm having a similar experience with dynamically rendering an element and hot reloading crashing on the second toggle. This does not occur with the target build (cargo build --release
).
If I strip out the inline CSS from your example, the problem disappears:
#![allow(non_snake_case)]
use dioxus::prelude::*;
use log::LevelFilter;
fn main() {
// Init debug
dioxus_logger::init(LevelFilter::Info).expect("failed to init logger");
console_error_panic_hook::set_once();
launch(SplashScreen);
}
#[component]
fn SplashScreen() -> Element {
rsx! {
div {
div {
div {
Footer {}
}
h1 { "sssss sit" },
}
}
}
}
#[component]
fn Footer() -> Element {
rsx! {
div {
div {
h1 { "Footer 1" }
}
div {
h1 { "Footer 2" }
}
}
}
}
As for my own case, I'm using a vanilla style sheet in the assets directory. I tried to come up with a simple example, but couldn't reproduce it.
So this works fine hot reloading:
#![allow(non_snake_case)]
use dioxus::prelude::*;
use log::LevelFilter;
#[derive(Clone, Routable, Debug, PartialEq)]
enum Route {
#[route("/")]
Home {},
}
fn main() {
// Init debug
dioxus_logger::init(LevelFilter::Info).expect("failed to init logger");
dioxus::launch(App);
}
#[component]
fn App() -> Element {
rsx! {
Router::<Route> {}
}
}
#[derive(Props, Clone, PartialEq)]
struct LoginProp {
logged_in: bool,
}
#[component]
fn LoginComponent(props: LoginProp) -> Element {
let LoginProp { logged_in } = props;
if !logged_in {
return None;
}
rsx! {
p { class: "p-class", "You are logged in" }
}
}
#[component]
fn Home() -> Element {
let mut logged_in = use_signal(||false);
rsx! {
LoginComponent { logged_in: logged_in() }
button {
class: "button-class",
onclick: move |_| logged_in.toggle(),
"Log in",
}
}
}
But my actual use case which involves a similar but more complex setup for hiding a sidebar crashes. Removing the style sheet didn't solve the issue.
Environment:
Problem
Hot reloading panics:
panicked at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-core-0.5.0/src/arena.rs:57:32: cannot reclaim ElementId(9)
Steps To Reproduce
Steps to reproduce the behavior:
dx serve
Change "Modify it" text to anything.
Expected behavior
Hot-reloading picks up the text changes.
Screenshots
Environment:
web
Note
If footer code changed to the following code:
(notice divs have different width values)
hot reloading works as expected.
//cc @ickshonpe