feat: mvoe away from compound context
This commit is contained in:
1 parent
bfdcb20437
commit
a2c7d17b05
103 files changed
+309
-293
No files matched your search
@@ -15,7 +15,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
static App: FC<()> = |cx, props| {
|
||||
let (state, set_state) = use_state_classic(cx, || 0);
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
|
||||
@@ -27,7 +27,7 @@ enum Operator {
|
||||
Div,
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
static App: FC<()> = |cx, props| {
|
||||
let (cur_val, set_cur_val) = use_state_classic(cx, || 0.0_f64);
|
||||
let (operator, set_operator) = use_state_classic(cx, || None as Option<Operator>);
|
||||
let (display_value, set_display_value) = use_state_classic(cx, || "0".to_string());
|
||||
|
||||
@@ -13,7 +13,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
static App: FC<()> = |cx, props| {
|
||||
cx.render(rsx! {
|
||||
Calcier {
|
||||
h2 {"abc 1"}
|
||||
@@ -25,7 +25,7 @@ static App: FC<()> = |cx| {
|
||||
})
|
||||
};
|
||||
|
||||
static Calcier: FC<()> = |cx| {
|
||||
static Calcier: FC<()> = |cx, props| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
h1 {
|
||||
|
||||
@@ -25,7 +25,7 @@ fn main() {
|
||||
#[derive(Debug)]
|
||||
struct CustomContext([&'static str; 3]);
|
||||
|
||||
pub static Example: FC<()> = |cx| {
|
||||
pub static Example: FC<()> = |cx, props|{
|
||||
cx.use_create_context(|| CustomContext(["Jack", "Jill", "Bob"]));
|
||||
|
||||
cx.render(rsx! {
|
||||
|
||||
@@ -13,7 +13,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
static App: FC<()> = |cx, props| {
|
||||
cx.render(rsx! {
|
||||
h2 { "abc 1" }
|
||||
div {
|
||||
|
||||
@@ -13,7 +13,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(Example));
|
||||
}
|
||||
|
||||
pub static Example: FC<()> = |cx| {
|
||||
pub static Example: FC<()> = |cx, props| {
|
||||
let nodes = (0..500).map(|f| rsx! (li {"div"}));
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
|
||||
@@ -14,7 +14,7 @@ fn main() {
|
||||
}
|
||||
|
||||
// this is a component
|
||||
pub static Example: FC<()> = |cx| {
|
||||
pub static Example: FC<()> = |cx, props|{
|
||||
let (event, set_event) = use_state_classic(cx, || None);
|
||||
|
||||
let handler = move |evt| {
|
||||
@@ -50,7 +50,7 @@ struct ExampleProps {
|
||||
name: String,
|
||||
}
|
||||
|
||||
pub static Example2: FC<ExampleProps> = |cx| {
|
||||
pub static Example2: FC<ExampleProps> = |cx, props|{
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
h1 {"hello {cx.name}"}
|
||||
|
||||
@@ -12,7 +12,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
static App: FC<()> = |cx, props|{
|
||||
let (val, set_val) = use_state_classic(cx, || "asd".to_string());
|
||||
|
||||
cx.render(rsx! {
|
||||
@@ -37,7 +37,7 @@ static App: FC<()> = |cx| {
|
||||
})
|
||||
};
|
||||
|
||||
pub static Example: FC<()> = |cx| {
|
||||
pub static Example: FC<()> = |cx, props|{
|
||||
cx.render(rsx! {
|
||||
div { class: "max-w-lg max-w-xs bg-blue-800 shadow-2xl rounded-lg mx-auto text-center py-12 mt-4 rounded-xl"
|
||||
div { class: "container py-5 max-w-md mx-auto"
|
||||
@@ -50,7 +50,7 @@ pub static Example: FC<()> = |cx| {
|
||||
})
|
||||
};
|
||||
|
||||
static UserInput: FC<()> = |cx| {
|
||||
static UserInput: FC<()> = |cx, props|{
|
||||
let (val, set_val) = use_state_classic(cx, || "asd".to_string());
|
||||
|
||||
rsx! { in cx,
|
||||
|
||||
@@ -9,7 +9,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(Example))
|
||||
}
|
||||
|
||||
pub static Example: FC<()> = |cx| {
|
||||
pub static Example: FC<()> = |cx, props| {
|
||||
let (name, set_name) = use_state_classic(cx, || "...?");
|
||||
|
||||
log::debug!("Running component....");
|
||||
|
||||
@@ -9,7 +9,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(Example))
|
||||
}
|
||||
|
||||
pub static Example: FC<()> = |cx| {
|
||||
pub static Example: FC<()> = |cx, props| {
|
||||
let (name, set_name) = use_state_classic(cx, || "...?");
|
||||
cx.render(rsx! {
|
||||
section { class: "py-12 px-4 text-center"
|
||||
|
||||
@@ -14,7 +14,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
static App: FC<()> = |cx, props| {
|
||||
let (contents, set_contents) = use_state_classic(cx, || "asd");
|
||||
|
||||
cx.render(rsx! {
|
||||
|
||||
@@ -13,7 +13,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
static App: FC<()> = |cx, props| {
|
||||
let (contents, set_contents) = use_state_classic(cx, || "asd");
|
||||
|
||||
cx.render(rsx! {
|
||||
|
||||
@@ -26,7 +26,7 @@ pub struct TodoItem {
|
||||
pub contents: String,
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
static App: FC<()> = |cx, props| {
|
||||
let (draft, set_draft) = use_state_classic(cx, || "".to_string());
|
||||
let (filter, set_filter) = use_state_classic(cx, || FilterState::All);
|
||||
let todos = use_state(cx, || BTreeMap::<uuid::Uuid, TodoItem>::new());
|
||||
|
||||
@@ -11,7 +11,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(Example));
|
||||
}
|
||||
|
||||
pub static Example: FC<()> = |cx| {
|
||||
pub static Example: FC<()> = |cx, props| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
span {
|
||||
|
||||
@@ -31,7 +31,7 @@ fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(App));
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx| {
|
||||
static App: FC<()> = |cx, props| {
|
||||
let state = use_model(&cx, || Calculator::new());
|
||||
|
||||
let clear_display = state.display_value.eq("0");
|
||||
|
||||
@@ -27,7 +27,7 @@ struct ExampleProps {
|
||||
initial_name: &'static str,
|
||||
}
|
||||
|
||||
pub static Example: FC<ExampleProps> = |cx| {
|
||||
pub static Example: FC<ExampleProps> = |cx, props|{
|
||||
let name = use_state(cx, move || cx.initial_name);
|
||||
|
||||
cx.render(rsx! {
|
||||
|
||||
@@ -11,7 +11,7 @@ use dioxus_web::{prelude::*, WebsysRenderer};
|
||||
static APP_STYLE: &'static str = include_str!("./style.css");
|
||||
|
||||
fn main() {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(|cx| {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(|cx, props| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
id: "app"
|
||||
|
||||
@@ -9,7 +9,7 @@ fn main() {
|
||||
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(|cx| {
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(|cx, props| {
|
||||
cx.render(html! {
|
||||
<div>
|
||||
<div class="flex items-center justify-center flex-col">
|
||||
|
||||
Reference in new issue
Block a user