wip: prep to fix bug in create

This commit is contained in:
Jonathan Kelley committed 2022-11-15 23:22:41 -08:00
1 parent e09b6bf813
commit 04bc635ac5
14 files changed
+539 -57

No files matched your search

+8 -6
View File
@@ -16,15 +16,17 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let nf = NodeFactory::new(&cx);
// let nf = NodeFactory::new(&cx);
let mut attrs = dioxus::core::exports::bumpalo::collections::Vec::new_in(nf.bump());
// let mut attrs = dioxus::core::exports::bumpalo::collections::Vec::new_in(nf.bump());
attrs.push(nf.attr("client-id", format_args!("abc123"), None, false));
// attrs.push(nf.attr("client-id", format_args!("abc123"), None, false));
attrs.push(nf.attr("name", format_args!("bob"), None, false));
// attrs.push(nf.attr("name", format_args!("bob"), None, false));
attrs.push(nf.attr("age", format_args!("47"), None, false));
// attrs.push(nf.attr("age", format_args!("47"), None, false));
Some(nf.raw_element("my-element", None, &[], attrs.into_bump_slice(), &[], None))
// Some(nf.raw_element("my-element", None, &[], attrs.into_bump_slice(), &[], None))
todo!()
}
+1 -1
View File
@@ -15,7 +15,7 @@ fn app(cx: Scope) -> Element {
cx.render(rsx! {
div { "hello {name}!" }
Child {}
ChildWithRef{}
ChildWithRef {}
})
}
+2 -1
View File
@@ -2,12 +2,13 @@
//! It also proves that lifetimes work properly, especially when used with use_ref
use dioxus::prelude::*;
use dioxus_ssr::config::SsrConfig;
fn main() {
let mut vdom = VirtualDom::new(example);
vdom.rebuild();
let out = dioxus_ssr::render_vdom_cfg(&vdom, |c| c.newline(true).indent(true));
let out = dioxus_ssr::render_vdom_cfg(&vdom, SsrConfig::default().newline(true).indent(true));
println!("{}", out);
}
+18 -10
View File
@@ -6,15 +6,23 @@ fn main() {
fn app(cx: Scope) -> Element {
cx.render(rsx!(
// Use Map directly to lazily pull elements
(0..10).map(|f| rsx! { "{f}" }),
// Collect into an intermediate collection if necessary, and call into_iter
["a", "b", "c"]
.into_iter()
.map(|f| rsx! { "{f}" })
.collect::<Vec<_>>()
.into_iter(),
// Use optionals
Some(rsx! { "Some" }),
div { id: "123123123",
// Use Map directly to lazily pull elements
// (0..3).map(|f| rsx! { "{f}" }),
// Collect into an intermediate collection if necessary, and call into_iter
["a", "b", "c", "x", "y", "z"]
.into_iter()
.map(|f| rsx! { "{f}" })
.collect::<Vec<_>>()
.into_iter(),
["d", "e", "f"]
.into_iter()
.map(|f| rsx! { "{f}" })
.collect::<Vec<_>>()
.into_iter(),
// Use optionals
// Some(rsx! { "Some" }),
}
))
}
+3 -2
View File
@@ -5,6 +5,7 @@
use std::fmt::Write;
use dioxus::prelude::*;
use dioxus_ssr::config::SsrConfig;
fn main() {
// We can render VirtualDoms
@@ -25,14 +26,14 @@ fn main() {
// We can configure the SSR rendering to add ids for rehydration
println!(
"{}",
dioxus_ssr::render_vdom_cfg(&vdom, |c| c.pre_render(true))
dioxus_ssr::render_vdom_cfg(&vdom, SsrConfig::default().pre_render(true))
);
// We can even render as a writer
let mut file = String::new();
let _ = file.write_fmt(format_args!(
"{}",
dioxus_ssr::TextRenderer::from_vdom(&vdom, Default::default())
dioxus_ssr::SsrRender::default().render_vdom(&vdom)
));
println!("{}", file);
}