docs: update local examples and docs to support new syntaxes
This commit is contained in:
1 parent
e495b09bf1
commit
4de16c4779
118 files changed
+520
-1154
No files matched your search
@@ -16,10 +16,10 @@ use dioxus::prelude::*;
|
||||
pub struct MyProps {
|
||||
should_show: bool,
|
||||
}
|
||||
pub static Example0: FC<MyProps> = |cx, props| {
|
||||
pub static Example0: Component<MyProps> = |cx| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
{props.should_show.then(|| rsx!{
|
||||
{cx.props.should_show.then(|| rsx!{
|
||||
h1 { "showing the title!" }
|
||||
})}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ pub static Example0: FC<MyProps> = |cx, props| {
|
||||
pub struct MyProps1 {
|
||||
should_show: bool,
|
||||
}
|
||||
pub static Example1: FC<MyProps1> = |cx, props| {
|
||||
pub static Example1: Component<MyProps1> = |cx| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
// With matching
|
||||
@@ -77,7 +77,7 @@ pub enum Color {
|
||||
pub struct MyProps2 {
|
||||
color: Color,
|
||||
}
|
||||
pub static Example2: FC<MyProps2> = |cx, props| {
|
||||
pub static Example2: Component<MyProps2> = |cx| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
{match props.color {
|
||||
@@ -89,9 +89,9 @@ pub static Example2: FC<MyProps2> = |cx, props| {
|
||||
})
|
||||
};
|
||||
|
||||
pub static Example: FC<()> = |cx, props| {
|
||||
let should_show = use_state(cx, || false);
|
||||
let mut color_index = use_state(cx, || 0);
|
||||
pub static Example: Component<()> = |cx| {
|
||||
let should_show = use_state(&cx, || false);
|
||||
let mut color_index = use_state(&cx, || 0);
|
||||
let color = match *color_index % 2 {
|
||||
2 => Color::Green,
|
||||
1 => Color::Yellow,
|
||||
|
||||
Reference in new issue
Block a user