docs: update local examples and docs to support new syntaxes

This commit is contained in:
Jonathan Kelley committed 2021-12-15 15:56:53 -05:00
1 parent e495b09bf1
commit 4de16c4779
118 files changed
+520 -1154

No files matched your search

+3 -3
View File
@@ -8,7 +8,7 @@ use dioxus_html as dioxus_elements;
fn main() {
console_error_panic_hook::set_once();
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
dioxus_web::launch(APP, |c| c)
dioxus_web::launch(APP)
}
#[derive(serde::Deserialize)]
@@ -16,8 +16,8 @@ struct DogApi {
message: String,
}
static APP: FC<()> = |(cx, _props)| {
let state = use_state(cx, || 0);
static APP: Component<()> = |(cx, _props)| {
let state = use_state(&cx, || 0);
const ENDPOINT: &str = "https://dog.ceo/api/breeds/image/random/";
let doggo = use_suspense(
+6 -6
View File
@@ -11,13 +11,13 @@ fn main() {
console_error_panic_hook::set_once();
// Run the app
dioxus_web::launch(APP, |c| c)
dioxus_web::launch(APP)
}
static APP: FC<()> = |cx, _| {
let mut count = use_state(cx, || 3);
let content = use_state(cx, || String::from("h1"));
let text_content = use_state(cx, || String::from("Hello, world!"));
static APP: Component<()> = |cx| {
let mut count = use_state(&cx, || 3);
let content = use_state(&cx, || String::from("h1"));
let text_content = use_state(&cx, || String::from("Hello, world!"));
cx.render(rsx! {
div {
@@ -86,4 +86,4 @@ fn render_list(cx: Context, count: usize) -> Element {
rsx!(cx, ul { {items} })
}
static CHILD: FC<()> = |cx, _| rsx!(cx, div {"hello child"});
static CHILD: Component<()> = |cx, _| rsx!(cx, div {"hello child"});
+3 -3
View File
@@ -21,11 +21,11 @@ fn main() {
console_error_panic_hook::set_once();
// Run the app
dioxus_web::launch(App, |c| c)
dioxus_web::launch(App)
}
static App: FC<()> = |cx, props| {
let mut state = use_state(cx, || 0);
static App: Component<()> = |cx| {
let mut state = use_state(&cx, || 0);
cx.render(rsx! {
div {
style: {
+5 -5
View File
@@ -18,12 +18,12 @@ use dioxus_html as dioxus_elements;
// #[cfg]
fn main() {
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
dioxus_web::launch(App, |c| c);
dioxus_web::launch(App);
// env_logger::init();
// dioxus::web::launch(App, |c| c);
// dioxus::web::launch(App);
}
static App: FC<()> = |cx, props| {
static App: Component<()> = |cx| {
dbg!("rednering parent");
cx.render(rsx! {
div {
@@ -40,8 +40,8 @@ static App: FC<()> = |cx, props| {
})
};
static But: FC<()> = |cx, props| {
let mut count = use_state(cx, || 0);
static But: Component<()> = |cx| {
let mut count = use_state(&cx, || 0);
// let d = Dropper { name: "asd" };
// let handler = move |_| {
+7 -7
View File
@@ -12,7 +12,7 @@ fn main() {
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
console_error_panic_hook::set_once();
dioxus_web::launch(App, |c| c)
dioxus_web::launch(App)
}
enum Scene {
@@ -28,13 +28,13 @@ pub struct Client {
pub description: String,
}
static App: FC<()> = |cx, _| {
let scene = use_state(cx, || Scene::ClientsList);
let clients = use_ref(cx, || vec![] as Vec<Client>);
static App: Component<()> = |cx| {
let scene = use_state(&cx, || Scene::ClientsList);
let clients = use_ref(&cx, || vec![] as Vec<Client>);
let firstname = use_state(cx, || String::new());
let lastname = use_state(cx, || String::new());
let description = use_state(cx, || String::new());
let firstname = use_state(&cx, || String::new());
let lastname = use_state(&cx, || String::new());
let description = use_state(&cx, || String::new());
let scene = match *scene {
Scene::ClientsList => {
+7 -7
View File
@@ -21,10 +21,10 @@ fn main() {
console_error_panic_hook::set_once();
// Run the app
dioxus_web::launch(App, |c| c)
dioxus_web::launch(App)
}
pub static App: FC<()> = |cx, props| {
pub static App: Component<()> = |cx| {
cx.render(rsx!(
div { class: "overflow-hidden"
link { href:"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel:"stylesheet" }
@@ -39,7 +39,7 @@ pub static App: FC<()> = |cx, props| {
))
};
pub static Header: FC<()> = |cx, props| {
pub static Header: Component<()> = |cx| {
cx.render(rsx! {
div {
header { class: "text-gray-400 bg-gray-900 body-font"
@@ -65,7 +65,7 @@ pub static Header: FC<()> = |cx, props| {
})
};
pub static Hero: FC<()> = |cx, props| {
pub static Hero: Component<()> = |cx| {
//
cx.render(rsx! {
section{ class: "text-gray-400 bg-gray-900 body-font"
@@ -103,7 +103,7 @@ pub static Hero: FC<()> = |cx, props| {
}
})
};
pub static Entry: FC<()> = |cx, props| {
pub static Entry: Component<()> = |cx| {
//
cx.render(rsx! {
section{ class: "text-gray-400 bg-gray-900 body-font"
@@ -116,7 +116,7 @@ pub static Entry: FC<()> = |cx, props| {
})
};
pub static StacksIcon: FC<()> = |cx, props| {
pub static StacksIcon: Component<()> = |cx| {
cx.render(rsx!(
svg {
// xmlns: "http://www.w3.org/2000/svg"
@@ -131,7 +131,7 @@ pub static StacksIcon: FC<()> = |cx, props| {
}
))
};
pub static RightArrowIcon: FC<()> = |cx, props| {
pub static RightArrowIcon: Component<()> = |cx| {
cx.render(rsx!(
svg {
fill: "none"