Skip to content

Commit fd93ee8

Browse files
committed
feat: upgrade syntax
1 parent 574d7fd commit fd93ee8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+522
-437
lines changed

examples/core/async.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn main() {
55
dom.rebuild();
66
}
77

8-
const App: FC<()> = |(cx, props)| {
8+
const App: FC<()> = |cx, props| {
99
let id = cx.scope_id();
1010
// cx.submit_task(Box::pin(async move { id }));
1111

examples/core/contextapi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct SomeContext {
66
}
77

88
#[allow(unused)]
9-
static Example: FC<()> = |(cx, props)| {
9+
static Example: FC<()> = |cx, props| {
1010
todo!()
1111

1212
// let value = cx.use_context(|c: &SomeContext| c.items.last().unwrap());

examples/core/syntax.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn html_usage() {
3333

3434
static App2: FC<()> = |(cx, _)| cx.render(rsx!("hello world!"));
3535

36-
static App: FC<()> = |(cx, props)| {
36+
static App: FC<()> = |cx, props| {
3737
let name = cx.use_state(|| 0);
3838

3939
cx.render(rsx!(div {
@@ -99,7 +99,7 @@ impl<'a> Children<'a> {
9999
}
100100
}
101101

102-
static Bapp: FC<()> = |(cx, props)| {
102+
static Bapp: FC<()> = |cx, props| {
103103
let name = cx.use_state(|| 0);
104104

105105
cx.render(rsx!(
@@ -114,7 +114,7 @@ static Bapp: FC<()> = |(cx, props)| {
114114
))
115115
};
116116

117-
static Match: FC<()> = |(cx, props)| {
117+
static Match: FC<()> = |cx, props| {
118118
//
119119
let b: Box<dyn Fn(NodeFactory) -> VNode> = Box::new(|f| todo!());
120120

examples/core/vdom_usage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use dioxus_core::{lazynodes::LazyNodes, prelude::*};
55
// #[async_std::main]
66
fn main() {
77
static App: FC<()> =
8-
|(cx, props)| cx.render(Some(LazyNodes::new(move |f| f.text(format_args!("hello")))));
8+
|cx, props| cx.render(Some(LazyNodes::new(move |f| f.text(format_args!("hello")))));
99

1010
let mut dom = VirtualDom::new(App);
1111

examples/core_reference/antipatterns.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use dioxus::prelude::*;
3232
struct NoKeysProps {
3333
data: std::collections::HashMap<u32, String>,
3434
}
35-
static AntipatternNoKeys: FC<NoKeysProps> = |(cx, props)| {
35+
static AntipatternNoKeys: FC<NoKeysProps> = |cx, props| {
3636
// WRONG: Make sure to add keys!
3737
rsx!(cx, ul {
3838
{props.data.iter().map(|(k, v)| rsx!(li { "List item: {v}" }))}
@@ -54,7 +54,7 @@ static AntipatternNoKeys: FC<NoKeysProps> = |(cx, props)| {
5454
///
5555
/// Only Component and Fragment nodes are susceptible to this issue. Dioxus mitigates this with components by providing
5656
/// an API for registering shared state without the ContextProvider pattern.
57-
static AntipatternNestedFragments: FC<()> = |(cx, props)| {
57+
static AntipatternNestedFragments: FC<()> = |cx, props| {
5858
// Try to avoid heavily nesting fragments
5959
rsx!(cx,
6060
Fragment {
@@ -82,7 +82,7 @@ static AntipatternNestedFragments: FC<()> = |(cx, props)| {
8282
/// However, calling set_state will *not* update the current version of state in the component. This should be easy to
8383
/// recognize from the function signature, but Dioxus will not update the "live" version of state. Calling `set_state`
8484
/// merely places a new value in the queue and schedules the component for a future update.
85-
static AntipatternRelyingOnSetState: FC<()> = |(cx, props)| {
85+
static AntipatternRelyingOnSetState: FC<()> = |cx, props| {
8686
let (state, set_state) = use_state(cx, || "Hello world").classic();
8787
set_state("New state");
8888
// This will return false! `state` will *still* be "Hello world"
@@ -99,7 +99,7 @@ static AntipatternRelyingOnSetState: FC<()> = |(cx, props)| {
9999
/// - All components must start with an uppercase character
100100
///
101101
/// i.e.: the following component will be rejected when attempted to be used in the rsx! macro
102-
static antipattern_component: FC<()> = |(cx, props)| todo!();
102+
static antipattern_component: FC<()> = |cx, props| todo!();
103103

104104
/// Antipattern: Misusing hooks
105105
/// ---------------------------
@@ -120,7 +120,7 @@ static antipattern_component: FC<()> = |(cx, props)| todo!();
120120
struct MisuedHooksProps {
121121
should_render_state: bool,
122122
}
123-
static AntipatternMisusedHooks: FC<MisuedHooksProps> = |(cx, props)| {
123+
static AntipatternMisusedHooks: FC<MisuedHooksProps> = |cx, props| {
124124
if props.should_render_state {
125125
// do not place a hook in the conditional!
126126
// prefer to move it out of the conditional
@@ -153,7 +153,7 @@ static AntipatternMisusedHooks: FC<MisuedHooksProps> = |(cx, props)| {
153153
/// }
154154
/// }
155155
/// })
156-
static _example: FC<()> = |(cx, props)| todo!();
156+
static _example: FC<()> = |cx, props| todo!();
157157

158158
/// Antipattern: publishing components and hooks with all features enabled
159159
/// ----------------------------------------------------------------------
@@ -171,9 +171,9 @@ static _example: FC<()> = |(cx, props)| todo!();
171171
///
172172
/// This will only include the `core` dioxus crate which is relatively slim and fast to compile and avoids target-specific
173173
/// libraries.
174-
static __example: FC<()> = |(cx, props)| todo!();
174+
static __example: FC<()> = |cx, props| todo!();
175175

176-
pub static Example: FC<()> = |(cx, props)| {
176+
pub static Example: FC<()> = |cx, props| {
177177
cx.render(rsx! {
178178
AntipatternNoKeys { data: std::collections::HashMap::new() }
179179
AntipatternNestedFragments {}

examples/core_reference/basics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
use dioxus::prelude::*;
1111

12-
pub static Example: FC<()> = |(cx, props)| {
12+
pub static Example: FC<()> = |cx, props| {
1313
cx.render(rsx! {
1414
div {
1515
Greeting {
@@ -25,7 +25,7 @@ struct GreetingProps {
2525
name: &'static str,
2626
}
2727

28-
static Greeting: FC<GreetingProps> = |(cx, props)| {
28+
static Greeting: FC<GreetingProps> = |cx, props| {
2929
cx.render(rsx! {
3030
div {
3131
h1 { "Hello, {props.name}!" }

examples/core_reference/children.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
use dioxus::prelude::*;
2020

21-
pub static Example: FC<()> = |(cx, props)| {
21+
pub static Example: FC<()> = |cx, props| {
2222
cx.render(rsx! {
2323
div {
2424
Banner {
@@ -31,7 +31,7 @@ pub static Example: FC<()> = |(cx, props)| {
3131
})
3232
};
3333

34-
pub static Banner: FC<()> = |(cx, props)| {
34+
pub static Banner: FC<()> = |cx, props| {
3535
cx.render(rsx! {
3636
div {
3737
h1 { "This is a great banner!" }

examples/core_reference/conditional_rendering.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use dioxus::prelude::*;
1616
pub struct MyProps {
1717
should_show: bool,
1818
}
19-
pub static Example0: FC<MyProps> = |(cx, props)| {
19+
pub static Example0: FC<MyProps> = |cx, props| {
2020
cx.render(rsx! {
2121
div {
2222
{props.should_show.then(|| rsx!{
@@ -39,7 +39,7 @@ pub static Example0: FC<MyProps> = |(cx, props)| {
3939
pub struct MyProps1 {
4040
should_show: bool,
4141
}
42-
pub static Example1: FC<MyProps1> = |(cx, props)| {
42+
pub static Example1: FC<MyProps1> = |cx, props| {
4343
cx.render(rsx! {
4444
div {
4545
// With matching
@@ -77,7 +77,7 @@ pub enum Color {
7777
pub struct MyProps2 {
7878
color: Color,
7979
}
80-
pub static Example2: FC<MyProps2> = |(cx, props)| {
80+
pub static Example2: FC<MyProps2> = |cx, props| {
8181
cx.render(rsx! {
8282
div {
8383
{match props.color {
@@ -89,7 +89,7 @@ pub static Example2: FC<MyProps2> = |(cx, props)| {
8989
})
9090
};
9191

92-
pub static Example: FC<()> = |(cx, props)| {
92+
pub static Example: FC<()> = |cx, props| {
9393
let should_show = use_state(cx, || false);
9494
let mut color_index = use_state(cx, || 0);
9595
let color = match *color_index % 2 {

examples/core_reference/controlled_inputs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use dioxus::prelude::*;
22
fn main() {}
33

4-
pub static Example: FC<()> = |(cx, props)| {
4+
pub static Example: FC<()> = |cx, props| {
55
cx.render(rsx! {
66
div {
77

@@ -10,7 +10,7 @@ pub static Example: FC<()> = |(cx, props)| {
1010
};
1111

1212
// A controlled component:
13-
static ControlledSelect: FC<()> = |(cx, props)| {
13+
static ControlledSelect: FC<()> = |cx, props| {
1414
let value = use_state(cx, || String::from("Grapefruit"));
1515
cx.render(rsx! {
1616
select { value: "{value}", onchange: move |evt| value.set(evt.value()),
@@ -23,7 +23,7 @@ static ControlledSelect: FC<()> = |(cx, props)| {
2323
};
2424

2525
// TODO - how do uncontrolled things work?
26-
static UncontrolledSelect: FC<()> = |(cx, props)| {
26+
static UncontrolledSelect: FC<()> = |cx, props| {
2727
let value = use_state(cx, || String::new());
2828

2929
cx.render(rsx! {

examples/core_reference/custom_elements.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
use dioxus::prelude::*;
1313

14-
pub static Example: FC<()> = |(cx, props)| {
14+
pub static Example: FC<()> = |cx, props| {
1515
cx.render(rsx! {
1616
div {
1717
custom_element {

0 commit comments

Comments
 (0)