wip: move some examples around

This commit is contained in:
Jonathan Kelley committed 2021-07-07 16:19:10 -04:00
1 parent cca7c5fc3a
commit 98a09339fd
70 files changed
+111 -117

No files matched your search

+2 -2
View File
@@ -85,7 +85,7 @@ static AntipatternNestedFragments: FC<()> = |cx| {
/// recognize from the function signature, but Dioxus will not update the "live" version of state. Calling `set_state`
/// merely places a new value in the queue and schedules the component for a future update.
static AntipaternRelyingOnSetState: FC<()> = |cx| {
let (state, set_state) = use_state_classic(&cx, || "Hello world");
let (state, set_state) = use_state_classic(cx, || "Hello world");
set_state("New state");
// This will return false! `state` will *still* be "Hello world"
assert!(state == &"New state");
@@ -126,7 +126,7 @@ static AntipatternMisusedHooks: FC<MisuedHooksProps> = |cx| {
if cx.should_render_state {
// do not place a hook in the conditional!
// prefer to move it out of the conditional
let (state, set_state) = use_state_classic(&cx, || "hello world");
let (state, set_state) = use_state_classic(cx, || "hello world");
rsx!(in cx, div { "{state}" })
} else {
rsx!(in cx, div { "Not rendering state" })
+2 -5
View File
@@ -7,9 +7,6 @@ use dioxus::prelude::*;
fn main() {}
static Example: FC<()> = |cx| {
cx.render(rsx! {
div {
}
})
//
cx.render(rsx! {})
};
+1 -1
View File
@@ -2,7 +2,7 @@ use dioxus::prelude::*;
fn main() {}
static Example: FC<()> = |cx| {
let (g, set_g) = use_state_classic(&cx, || 0);
let (g, set_g) = use_state_classic(cx, || 0);
let v = (0..10).map(|f| {
rsx! {
li {
+1 -1
View File
@@ -11,7 +11,7 @@ fn main() {}
/// We can use `set_name` in multiple closures; the closures automatically *copy* the reference to set_name.
static ButtonList: FC<()> = |cx| {
let (name, set_name) = use_state_classic(&cx, || "...?");
let (name, set_name) = use_state_classic(cx, || "...?");
let names = ["jack", "jill", "john", "jane"]
.iter()