DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
20.32k stars 779 forks source link

render_lazy cant take components #354

Closed saicu closed 1 year ago

saicu commented 2 years ago

dioxus::ssr::render_lazy panics when giving it an empty component, see this small example

#[cfg(test)]
mod tests {
    use dioxus::prelude::*;

    fn TestEl(cx: Scope) -> Element {
        None
    }

    #[test]
    fn it_works() {
        let html = rsx! {
            div {
                TestEl {}
            }
        };

        let result = dioxus::ssr::render_lazy(html);
    }
}

fails with

---- tests::it_works stdout ----
thread 'tests::it_works' panicked at 'called `Option::unwrap()` on a `None` value', /home/sam/.cargo/git/checkouts/dioxus-1e619ce595d3799d/90a3093/packages/ssr/src/lib.rs:276:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
pfesenmeier commented 2 years ago

I am also seeing this behavior on non-empty components.

I have gotten around the issue by rendering VirtualDoms instead https://dioxuslabs.com/reference/platforms/ssr.html

jkelleyrtp commented 1 year ago

This is fixed now!