fix dioxus ssr

This commit is contained in:
Evan Almloff committed 2024-01-10 17:57:15 -06:00
1 parent dc58212508
commit 4a1a00b0f0
27 files changed
+143 -141

No files matched your search

+8 -8
View File
@@ -18,7 +18,7 @@ This crate is a part of the broader Dioxus ecosystem. For more resources about D
Dioxus SSR provides utilities to render Dioxus components to valid HTML. Once rendered, the HTML can be rehydrated client-side or served from your web server of choice.
```rust, ignore
let app: Component = |cx| cx.render(rsx!(div {"hello world!"}));
let app: Component = |cx| render!(div {"hello world!"});
let mut vdom = VirtualDom::new(app);
let _ = vdom.rebuild();
@@ -29,12 +29,12 @@ assert_eq!(text, "<div>hello world!</div>")
## Basic Usage
The simplest example is to simply render some `rsx!` nodes to HTML. This can be done with the [`render_lazy`] API.
The simplest example is to simply render some `render!` nodes to HTML. This can be done with the [`render_element`] API.
```rust, ignore
let content = dioxus_ssr::render_lazy(rsx!{
let content = dioxus_ssr::render_element(render!{
div {
(0..5).map(|i| rsx!(
(0..5).map(|i| render!(
"Number: {i}"
))
}
@@ -84,19 +84,19 @@ The rest of the space - IE doing this more efficiently, caching the VirtualDom,
## Usage without a VirtualDom
Dioxus SSR needs an arena to allocate from - whether it be the VirtualDom or a dedicated Bump allocator. To render `rsx!` directly to a string, you'll want to create a `Renderer` and call `render_lazy`.
Dioxus SSR needs an arena to allocate from - whether it be the VirtualDom or a dedicated Bump allocator. To render `render!` directly to a string, you'll want to create a `Renderer` and call `render_element`.
```rust, ignore
let text = dioxus_ssr::Renderer::new().render_lazy(rsx!{
let text = dioxus_ssr::Renderer::new().render_element(render!{
div { "hello world" }
});
assert_eq!(text, "<div>hello world!</div>")
```
This can be automated with the `render_lazy!` macro:
This can be automated with the `render_element!` macro:
```rust, ignore
let text = render_lazy!(rsx!( div { "hello world" } ));
let text = render_element!(render!( div { "hello world" } ));
```
## Usage in static site generation