docs: big updates to the reference

This commit is contained in:
Jonathan Kelley committed 2021-07-16 16:11:25 -04:00
1 parent caf772cf24
commit 583fdfa561
57 files changed
+726 -247

No files matched your search

+1 -1
View File
@@ -60,7 +60,7 @@ Commas are entirely optional, but might be useful to delineate between elements
The `render` function provides an **extremely efficient** allocator for VNodes and text, so try not to use the `format!` macro in your components. Rust's default `ToString` methods pass through the global allocator, but all text in components is allocated inside a manually-managed Bump arena. To push you in the right direction, all text-based attributes take `std::fmt::Arguments` directly, so you'll want to reach for `format_args!` when the built-in `f-string` interpolation just doesn't cut it.
```rust
static Example: FC<()> = |cx| {
pub static Example: FC<()> = |cx| {
let text = "example";
+1 -1
View File
@@ -25,7 +25,7 @@ fn Example(cx: Context, name: String) -> VNode {
// or
#[functional_component]
static Example: FC = |cx, name: String| html! { <div> "Hello {name}!" </div> };
pub static Example: FC = |cx, name: String| html! { <div> "Hello {name}!" </div> };
```
The final output of components must be a tree of VNodes. We provide an html macro for using JSX-style syntax to write these, though, you could use any macro, DSL, templating engine, or the constructors directly.