-
-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hot reloading updating wrong part inside a conditional expression #1995
Comments
To be more exact the version I'm using is dioxus = { git = "https://github.com/ealmloff/dioxus.git", branch = "fix-fullstack-history" since routing was broken in 0.5.0 alpha. |
Also would be great to have more debug logging in Dioxus, to better see what's going on under the hood when something like this happens. |
It's always the last rsx expression that gets sent over the websocket when anything changes. So changing the order of match clauses will change the behavior. |
If you set Some part of the code diffing rsx here may be broken: dioxus/packages/rsx/src/hot_reload/hot_reload_diff.rs Lines 455 to 481 in 9ae3d14
I was unable to reproduce this issue with the CLI version installed from the latest commit on the use dioxus::prelude::*;
fn main() {
launch(app);
}
fn app() -> Element {
rsx! {
RecipeView { id: "1".to_string() }
}
}
#[component]
pub fn RecipeView(id: String) -> Element {
let recipe: Option<Result<usize, usize>> = Some(Ok(1));
match recipe {
Some(Ok(recipe)) => {
rsx! {
div { class: "flex flex-col justify-center overflow-hidden py-6",
div { class: "mx-auto max-w-2xl",
h1 { class: "text-5xl text-center font-extrabold py-3", "{recipe}" }
p { class: "text-4xl py-3", "{recipe}" }
p { "Another static text with more data" }
}
}
}
}
Some(Err(_)) => {
rsx! {"Error loading recipe"}
}
None => {
rsx! {"Loading..."}
}
}
} |
Maybe in your code example the compiler optimizes the other cases away, since you have a static value 😊 If I try with
|
Actually it seems like those two cases don't ever get to produce a template. When I force a long delay on the server call, I can see in the browser inspector that the component contents for |
Another weird thing I'm seeing in the logs is the execution of part of the server function multiple times.
So the code after the #[server]
pub async fn get_recipe(id: String) -> Result<Recipe, ServerFnError> {
println!("get_recipe: {}", id);
use tokio::time::{sleep, Duration};
sleep(Duration::from_millis(5000)).await;
println!("get_recipe: done");
Ok(Recipe {
id,
name: "Test Recipe".to_string(),
description: "This is a test recipe".to_string(),
ingredients: vec![],
steps: vec![],
})
} |
BTW didn't see those repeating |
The reason for this was the |
let recipe = use_server_future(move || {
get_recipe(id.clone())
})?; The Suspense boundaries are not implemented yet, but once they are you will be able to handle rendering a placeholder higher up in your component. |
Those logs will happen whenever a client makes a request to your server and the server renders the page. If you reload your page 5 times, you should see 5 logs. You may also more logs if an asset is trying to load that doesn't exist and you are rendering a page on a 404 route |
But I see in the logs only the |
I think this is a race condition on how we register templates. Templates are given a template ID but that ID assignment can vary depending on the order in which we process them. If the template doesn't exist on the client when we handle its edits, we have nothing to direct those edits to. Hence why you only see edits for the actually loaded block of rsx. This needs to be solved with more resilient handling of edits queued for nonexistent templates. |
Tracked it down - our implementation was only storing the most recent change and a max of 1 template per file. This is being fixed in #2055 along with a few other issues. |
Problem
When making changes in a component that has a match expression, hot reload only ever updates the last expression even when changes are made in other parts.
Steps To Reproduce
I have a following component
Serving the app with
dx serve --hot-reload
Make a change in one of the class definitions or in static text.
Monitor the messages in the
hot_reload
websocket.See that it always sends a message to update the "Loading..." text, regardless of what was actually changed.
Expected behavior
It should send a message to update the affected part of the page.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment:
Questionnaire
The text was updated successfully, but these errors were encountered: