Skip to content
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

Individual item render order is reversed #3673

Open
1 of 3 tasks
Cationiz3r opened this issue Jun 19, 2024 · 0 comments
Open
1 of 3 tasks

Individual item render order is reversed #3673

Cationiz3r opened this issue Jun 19, 2024 · 0 comments
Labels

Comments

@Cationiz3r
Copy link

Problem

The numbers are arranged in the correct order (from 1 to 5) after being rendered, but the order in which each is rendered, reported by gloo_console::debug!, are reversed (from 5 to 1).

I currently maintain a file managing application that display files in a grid.
When a directory contains images, their thumbnails will be rendered as img elements, but in the aforementioned order.
Because the browser sees the last element first, it also downloads and displays image data from last to first.
Over a weak internet connection, this becomes really noticeable, which is undesirable.

Steps To Reproduce
Run the following code (with trunk).

use yew::prelude::*;

#[derive(Debug, PartialEq, Properties)]
struct Properties {
    pub num: i32,
}

#[function_component]
fn Number(props: &Properties) -> Html {
    let num = props.num;
    gloo_console::debug!(format!("Render: {}", num)); // DEBUG:
    html! { <div>{ props.num }</div> }
}

#[function_component]
fn App() -> Html {
    let numbers = 1..=5;
    numbers.map(|num| html! { <Number {num} /> }).collect()
}

fn main() { yew::Renderer::<App>::new().render(); }

Expected behavior
I expect the debug messages to appear in the same order as the numbers.

Screenshots
Taken from the browser web console (Ctrl+Shift+K).

240619_131725

Environment:

  • Yew version: yew = { version = "0.21.0", features = ["csr"] }
  • Rust version: cargo 1.81.0-nightly (a1f47ec3f 2024-06-15)
  • Target, if relevant: wasm32-unknown-unknown
  • Build tool, if relevant: trunk
  • OS, if relevent: Linux 6.9.4-hardened1-1-hardened
  • Browser and version, if relevant: Firefox 126.0.1

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@Cationiz3r Cationiz3r added the bug label Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant