Feat: update fc_macro

This commit is contained in:
Jonathan Kelley committed 2021-01-21 02:25:44 -05:00
1 parent 6aeea9b790
commit 28ac37a8b2
12 files changed
+353 -230

No files matched your search

+5
View File
@@ -10,6 +10,7 @@ edition = "2018"
fern = { version = "0.6.0", features = ["colored"] }
log = "0.4.1"
dioxus = { path = "../packages/dioxus" }
dioxus-ssr = { path = "../packages/ssr" }
rand = "0.8.2"
@@ -43,3 +44,7 @@ name = "doc_generator"
[[example]]
path = "router.rs"
name = "router"
[[example]]
path = "fc_macro.rs"
name = "fc_macro"
+19
View File
@@ -0,0 +1,19 @@
use dioxus::prelude::*;
use dioxus_ssr::TextRenderer;
// todo @Jon, support components in the html! macro
// let renderer = TextRenderer::new(|_| html! {<Example name="world"/>});
fn main() {
let renderer = TextRenderer::<()>::new(|_| html! {<div> "Hello world" </div>});
let output = renderer.render();
}
/// An example component that demonstrates how to use the functional_component macro
/// This macro makes writing functional components elegant, similar to how Rocket parses URIs.
///
/// You don't actually *need* this macro to be productive, but it makes life easier, and components cleaner.
/// This approach also integrates well with tools like Rust-Analyzer
#[fc]
fn example(ctx: &Context, name: String) -> VNode {
html! { <div> "Hello, {name}!" </div> }
}