Skip to content

Commit 4eefc3f

Browse files
committed
chore: rename all &cx to cx, make clipppy happy
1 parent e8133e9 commit 4eefc3f

Some content is hidden

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

85 files changed

+256
-271
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Dioxus is a portable, performant, and ergonomic framework for building cross-pla
5454

5555
```rust
5656
fn app(cx: Scope) -> Element {
57-
let mut count = use_state(&cx, || 0);
57+
let mut count = use_state(cx, || 0);
5858

5959
cx.render(rsx! {
6060
h1 { "High-Five counter: {count}" }

docs/guide/examples/conditional_rendering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
}
77

88
pub fn App(cx: Scope) -> Element {
9-
let is_logged_in = use_state(&cx, || false);
9+
let is_logged_in = use_state(cx, || false);
1010

1111
cx.render(rsx!(LogIn {
1212
is_logged_in: **is_logged_in,

docs/guide/examples/hooks_bad.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ fn App(cx: Scope) -> Element {
1717
// But `if` statements only run if the conditional is true!
1818
// So we might violate rule 2.
1919
if you_are_happy && you_know_it {
20-
let something = use_state(&cx, || "hands");
20+
let something = use_state(cx, || "hands");
2121
println!("clap your {something}")
2222
}
2323

2424
// ✅ instead, *always* call use_state
2525
// You can put other stuff in the conditional though
26-
let something = use_state(&cx, || "hands");
26+
let something = use_state(cx, || "hands");
2727
if you_are_happy && you_know_it {
2828
println!("clap your {something}")
2929
}
@@ -33,12 +33,12 @@ fn App(cx: Scope) -> Element {
3333
// ❌ don't call hooks inside closures!
3434
// We can't guarantee that the closure, if used, will be called at the same time every time
3535
let _a = || {
36-
let b = use_state(&cx, || 0);
36+
let b = use_state(cx, || 0);
3737
b.get()
3838
};
3939

4040
// ✅ instead, move hook `b` outside
41-
let b = use_state(&cx, || 0);
41+
let b = use_state(cx, || 0);
4242
let _a = || b.get();
4343
// ANCHOR_END: closure
4444

@@ -50,12 +50,12 @@ fn App(cx: Scope) -> Element {
5050
// ❌ Do not use hooks in loops!
5151
// In this case, if the length of the Vec changes, we break rule 2
5252
for _name in &names {
53-
let is_selected = use_state(&cx, || false);
53+
let is_selected = use_state(cx, || false);
5454
println!("selected: {is_selected}");
5555
}
5656

5757
// ✅ Instead, use a hashmap with use_ref
58-
let selection_map = use_ref(&cx, HashMap::<&str, bool>::new);
58+
let selection_map = use_ref(cx, HashMap::<&str, bool>::new);
5959

6060
for name in &names {
6161
let is_selected = selection_map.read()[name];

docs/guide/examples/hooks_counter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77

88
// ANCHOR: component
99
fn App(cx: Scope) -> Element {
10-
let mut count = use_state(&cx, || 0);
10+
let mut count = use_state(cx, || 0);
1111

1212
cx.render(rsx!(
1313
h1 { "High-Five counter: {count}" }

docs/guide/examples/hooks_counter_two_state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ fn main() {
88
// ANCHOR: component
99
fn App(cx: Scope) -> Element {
1010
// ANCHOR: use_state_calls
11-
let mut count_a = use_state(&cx, || 0);
12-
let mut count_b = use_state(&cx, || 0);
11+
let mut count_a = use_state(cx, || 0);
12+
let mut count_b = use_state(cx, || 0);
1313
// ANCHOR_END: use_state_calls
1414

1515
cx.render(rsx!(

docs/guide/examples/hooks_use_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77

88
// ANCHOR: component
99
fn App(cx: Scope) -> Element {
10-
let list = use_ref(&cx, Vec::new);
10+
let list = use_ref(cx, Vec::new);
1111
let list_formatted = format!("{:?}", *list.read());
1212

1313
cx.render(rsx!(

docs/guide/examples/input_controlled.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77

88
// ANCHOR: component
99
fn App(cx: Scope) -> Element {
10-
let name = use_state(&cx, || "bob".to_string());
10+
let name = use_state(cx, || "bob".to_string());
1111

1212
cx.render(rsx! {
1313
input {

docs/guide/examples/meme_editor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn MemeEditor(cx: Scope) -> Element {
1818
width: fit-content;
1919
";
2020

21-
let caption = use_state(&cx, || "me waiting for my rust code to compile".to_string());
21+
let caption = use_state(cx, || "me waiting for my rust code to compile".to_string());
2222

2323
cx.render(rsx! {
2424
div {

docs/guide/examples/meme_editor_dark_mode.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ struct DarkMode(bool);
1414

1515
pub fn App(cx: Scope) -> Element {
1616
// ANCHOR: context_provider
17-
use_context_provider(&cx, || DarkMode(false));
17+
use_context_provider(cx, || DarkMode(false));
1818
// ANCHOR_END: context_provider
1919

20-
let is_dark_mode = use_is_dark_mode(&cx);
20+
let is_dark_mode = use_is_dark_mode(cx);
2121

2222
let wrapper_style = if is_dark_mode {
2323
r"
@@ -47,7 +47,7 @@ pub fn use_is_dark_mode(cx: &ScopeState) -> bool {
4747

4848
// ANCHOR: toggle
4949
pub fn DarkModeToggle(cx: Scope) -> Element {
50-
let dark_mode = use_context::<DarkMode>(&cx)?;
50+
let dark_mode = use_context::<DarkMode>(cx)?;
5151

5252
let style = if dark_mode.read().0 {
5353
"color:white"
@@ -71,7 +71,7 @@ pub fn DarkModeToggle(cx: Scope) -> Element {
7171

7272
// ANCHOR: meme_editor
7373
fn MemeEditor(cx: Scope) -> Element {
74-
let is_dark_mode = use_is_dark_mode(&cx);
74+
let is_dark_mode = use_is_dark_mode(cx);
7575
let heading_style = if is_dark_mode { "color: white" } else { "" };
7676

7777
let container_style = r"
@@ -82,7 +82,7 @@ fn MemeEditor(cx: Scope) -> Element {
8282
width: fit-content;
8383
";
8484

85-
let caption = use_state(&cx, || "me waiting for my rust code to compile".to_string());
85+
let caption = use_state(cx, || "me waiting for my rust code to compile".to_string());
8686

8787
cx.render(rsx! {
8888
div {
@@ -152,7 +152,7 @@ fn CaptionEditor<'a>(
152152
caption: &'a str,
153153
on_input: EventHandler<'a, FormData>,
154154
) -> Element<'a> {
155-
let is_dark_mode = use_is_dark_mode(&cx);
155+
let is_dark_mode = use_is_dark_mode(cx);
156156

157157
let colors = if is_dark_mode {
158158
r"

docs/guide/examples/rendering_lists.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ struct Comment {
1414

1515
pub fn App(cx: Scope) -> Element {
1616
// ANCHOR: render_list
17-
let comment_field = use_state(&cx, String::new);
18-
let mut next_id = use_state(&cx, || 0);
19-
let comments = use_ref(&cx, Vec::<Comment>::new);
17+
let comment_field = use_state(cx, String::new);
18+
let mut next_id = use_state(cx, || 0);
19+
let comments = use_ref(cx, Vec::<Comment>::new);
2020

2121
let comments_lock = comments.read();
2222
let comments_rendered = comments_lock.iter().map(|comment| {

0 commit comments

Comments
 (0)