wip: move some examples around
This commit is contained in:
1 parent
cca7c5fc3a
commit
98a09339fd
70 files changed
+111
-117
No files matched your search
@@ -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" })
|
||||
|
||||
@@ -7,9 +7,6 @@ use dioxus::prelude::*;
|
||||
fn main() {}
|
||||
|
||||
static Example: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
|
||||
}
|
||||
})
|
||||
//
|
||||
cx.render(rsx! {})
|
||||
};
|
||||
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user