chore: rename all &cx to cx, make clipppy happy

This commit is contained in:
Jonathan Kelley committed 2022-12-07 13:11:40 -08:00
1 parent e8133e9449
commit 4eefc3f854
85 files changed
+256 -271

No files matched your search

+1 -1
View File
@@ -41,7 +41,7 @@ const RECT_STYLE: &str = r#"
"#;
fn app(cx: Scope) -> Element {
let events = use_ref(&cx, std::collections::VecDeque::new);
let events = use_ref(cx, std::collections::VecDeque::new);
let log_event = move |event: Event| {
let mut events = events.write();
+1 -1
View File
@@ -19,7 +19,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let val = use_state(&cx, || String::from("0"));
let val = use_state(cx, || String::from("0"));
let input_digit = move |num: u8| {
if val.get() == "0" {
+4 -4
View File
@@ -16,10 +16,10 @@ pub struct Client {
}
fn app(cx: Scope) -> Element {
let clients = use_ref(&cx, || vec![] as Vec<Client>);
let firstname = use_state(&cx, String::new);
let lastname = use_state(&cx, String::new);
let description = use_state(&cx, String::new);
let clients = use_ref(cx, || vec![] as Vec<Client>);
let firstname = use_state(cx, String::new);
let lastname = use_state(cx, String::new);
let description = use_state(cx, String::new);
cx.render(rsx!(
body {
+1 -1
View File
@@ -16,7 +16,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
// let nf = NodeFactory::new(&cx);
// let nf = NodeFactory::new(cx);
// let mut attrs = dioxus::core::exports::bumpalo::collections::Vec::new_in(nf.bump());
+1 -1
View File
@@ -5,7 +5,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let disabled = use_state(&cx, || false);
let disabled = use_state(cx, || false);
cx.render(rsx! {
div {
+1 -1
View File
@@ -5,7 +5,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let val = use_state(&cx, || "0.0001");
let val = use_state(cx, || "0.0001");
let num = match val.parse::<f32>() {
Err(_) => return cx.render(rsx!("Parsing failed")),
+2 -2
View File
@@ -5,8 +5,8 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let script = use_state(&cx, String::new);
let eval = dioxus_desktop::use_eval(&cx);
let script = use_state(cx, String::new);
let eval = dioxus_desktop::use_eval(cx);
cx.render(rsx! {
div {
+3 -3
View File
@@ -10,7 +10,7 @@ fn main() {
static NAME: Atom<String> = |_| "world".to_string();
fn app(cx: Scope) -> Element {
let name = use_read(&cx, NAME);
let name = use_read(cx, NAME);
cx.render(rsx! {
div { "hello {name}!" }
@@ -20,7 +20,7 @@ fn app(cx: Scope) -> Element {
}
fn Child(cx: Scope) -> Element {
let set_name = use_set(&cx, NAME);
let set_name = use_set(cx, NAME);
cx.render(rsx! {
button {
@@ -33,7 +33,7 @@ fn Child(cx: Scope) -> Element {
static NAMES: AtomRef<Vec<String>> = |_| vec!["world".to_string()];
fn ChildWithRef(cx: Scope) -> Element {
let names = use_atom_ref(&cx, NAMES);
let names = use_atom_ref(cx, NAMES);
cx.render(rsx! {
div {
+1 -1
View File
@@ -19,7 +19,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let files = use_ref(&cx, Files::new);
let files = use_ref(cx, Files::new);
cx.render(rsx! {
div {
+2 -2
View File
@@ -32,8 +32,8 @@ impl Label {
}
fn app(cx: Scope) -> Element {
let items = use_ref(&cx, Vec::new);
let selected = use_state(&cx, || None);
let items = use_ref(cx, Vec::new);
let selected = use_state(cx, || None);
cx.render(rsx! {
div { class: "container",
+1 -1
View File
@@ -20,7 +20,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let val = use_state(&cx, || 0);
let val = use_state(cx, || 0);
cx.render(rsx! {
div {
+1 -1
View File
@@ -28,7 +28,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let state = use_state(&cx, || 1);
let state = use_state(cx, || 1);
cx.render(rsx! {
div {
+1 -1
View File
@@ -36,7 +36,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let state = use_ref(&cx, Calculator::new);
let state = use_ref(cx, Calculator::new);
cx.render(rsx! {
style { include_str!("./assets/calculator.css") }
+1 -1
View File
@@ -15,7 +15,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let state = use_state(&cx, PlayerState::new);
let state = use_state(cx, PlayerState::new);
cx.render(rsx!(
div {
+1 -1
View File
@@ -9,7 +9,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let mut count = use_state(&cx, || 0);
let mut count = use_state(cx, || 0);
cx.render(rsx! {
h1 { "High-Five counter: {count}" }
+3 -3
View File
@@ -30,7 +30,7 @@ fn app(cx: Scope) -> Element {
}
fn BlogPost(cx: Scope) -> Element {
let post = dioxus_router::use_route(&cx).last_segment().unwrap();
let post = dioxus_router::use_route(cx).last_segment().unwrap();
cx.render(rsx! {
div {
@@ -46,9 +46,9 @@ struct Query {
}
fn User(cx: Scope) -> Element {
let post = dioxus_router::use_route(&cx).last_segment().unwrap();
let post = dioxus_router::use_route(cx).last_segment().unwrap();
let query = dioxus_router::use_route(&cx)
let query = dioxus_router::use_route(cx)
.query::<Query>()
.unwrap_or(Query { bold: false });
+3 -3
View File
@@ -13,14 +13,14 @@ fn main() {
}
fn example(cx: Scope) -> Element {
let items = use_state(&cx, || {
let items = use_state(cx, || {
vec![Thing {
a: "asd".to_string(),
b: 10,
}]
});
let things = use_ref(&cx, || {
let things = use_ref(cx, || {
vec![Thing {
a: "asd".to_string(),
b: 10,
@@ -28,7 +28,7 @@ fn example(cx: Scope) -> Element {
});
let things_list = things.read();
let mything = use_ref(&cx, || Some(String::from("asd")));
let mything = use_ref(cx, || Some(String::from("asd")));
let mything_read = mything.read();
cx.render(rsx!(
+1 -1
View File
@@ -200,7 +200,7 @@ fn app(cx: Scope) -> Element {
// helper functions
// Anything that implements IntoVnode can be dropped directly into Rsx
helper(&cx, "hello world!")
helper(cx, "hello world!")
// Strings can be supplied directly
String::from("Hello world!")
+5 -13
View File
@@ -2,16 +2,13 @@
//!
//! This example shows how we can render the Dioxus Virtualdom using SSR.
use std::fmt::Write;
use dioxus::prelude::*;
use dioxus_ssr::config::Config;
fn main() {
// We can render VirtualDoms
let mut vdom = VirtualDom::new(app);
let _ = vdom.rebuild();
println!("{}", dioxus_ssr::render_vdom(&vdom));
println!("{}", dioxus_ssr::render(&vdom));
// Or we can render rsx! calls themselves
println!(
@@ -24,17 +21,12 @@ fn main() {
);
// We can configure the SSR rendering to add ids for rehydration
println!(
"{}",
dioxus_ssr::render_vdom_cfg(&vdom, Config::default().pre_render(true))
);
println!("{}", dioxus_ssr::pre_render(&vdom));
// We can even render as a writer
// We can render to a buf directly too
let mut file = String::new();
let _ = file.write_fmt(format_args!(
"{}",
dioxus_ssr::SsrRender::default().render_vdom(&vdom)
));
let mut renderer = dioxus_ssr::Renderer::default();
renderer.render_to(&mut file, &vdom).unwrap();
println!("{}", file);
}
+1 -1
View File
@@ -53,7 +53,7 @@ fn app(cx: Scope) -> Element {
/// Suspense is achieved my moving the future into only the component that
/// actually renders the data.
fn Doggo(cx: Scope) -> Element {
let fut = use_future(&cx, (), |_| async move {
let fut = use_future(cx, (), |_| async move {
reqwest::get("https://dog.ceo/api/breeds/image/random/")
.await
.unwrap()
+1 -1
View File
@@ -7,7 +7,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let val = use_state(&cx, || 5);
let val = use_state(cx, || 5);
cx.render(rsx! {
div {
+2 -2
View File
@@ -10,9 +10,9 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let count = use_state(&cx, || 0);
let count = use_state(cx, || 0);
use_future(&cx, (), move |_| {
use_future(cx, (), move |_| {
let mut count = count.clone();
async move {
loop {
+1 -1
View File
@@ -7,7 +7,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let model = use_state(&cx, || String::from("asd"));
let model = use_state(cx, || String::from("asd"));
println!("{}", model);
+4 -4
View File
@@ -12,15 +12,15 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let window = dioxus_desktop::use_window(&cx);
let window = dioxus_desktop::use_window(cx);
// if you want to make window fullscreen, you need close the resizable.
// window.set_fullscreen(true);
// window.set_resizable(false);
let fullscreen = use_state(&cx, || false);
let always_on_top = use_state(&cx, || false);
let decorations = use_state(&cx, || false);
let fullscreen = use_state(cx, || false);
let always_on_top = use_state(cx, || false);
let decorations = use_state(cx, || false);
cx.render(rsx!(
link { href:"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css", rel:"stylesheet" }
+2 -2
View File
@@ -6,9 +6,9 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let window = use_window(&cx);
let window = use_window(cx);
let level = use_state(&cx, || 1.0);
let level = use_state(cx, || 1.0);
cx.render(rsx! {
input {
r#type: "number",
+1 -1
View File
@@ -9,7 +9,7 @@ fn main() {
}
fn app(cx: Scope) -> Element {
let contents = use_state(&cx, || {
let contents = use_state(cx, || {
String::from("<script>alert(\"hello world\")</script>")
});