wip: remove portals completely
This commit is contained in:
1 parent
8daf7a6ed8
commit
2fd56e7619
17 files changed
+259
-404
No files matched your search
@@ -0,0 +1,16 @@
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_core as dioxus;
|
||||
use dioxus_core_macro::*;
|
||||
use dioxus_hooks::use_state;
|
||||
use dioxus_html as dioxus_elements;
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn App(cx: Scope<()>) -> Element {
|
||||
let color = use_state(&cx, || "white");
|
||||
|
||||
cx.render(rsx!(
|
||||
div { onclick: move |_| color.set("red"), "red" }
|
||||
div { onclick: move |_| color.set("blue"), "blue" }
|
||||
))
|
||||
}
|
||||
@@ -20,7 +20,7 @@ use dioxus_html as dioxus_elements;
|
||||
use rand::prelude::*;
|
||||
|
||||
fn main() {
|
||||
static App: Component<()> = |cx, _| {
|
||||
static App: Component<()> = |cx| {
|
||||
let mut rng = SmallRng::from_entropy();
|
||||
let rows = (0..10_000_usize).map(|f| {
|
||||
let label = Label::new(&mut rng);
|
||||
@@ -50,11 +50,11 @@ struct RowProps {
|
||||
row_id: usize,
|
||||
label: Label,
|
||||
}
|
||||
fn Row(cx: Scope, props: &RowProps) -> Element {
|
||||
let [adj, col, noun] = props.label.0;
|
||||
fn Row(cx: Scope<RowProps>) -> Element {
|
||||
let [adj, col, noun] = cx.props.label.0;
|
||||
cx.render(rsx! {
|
||||
tr {
|
||||
td { class:"col-md-1", "{props.row_id}" }
|
||||
td { class:"col-md-1", "{cx.props.row_id}" }
|
||||
td { class:"col-md-1", onclick: move |_| { /* run onselect */ }
|
||||
a { class: "lbl", "{adj}" "{col}" "{noun}" }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ fn main() {
|
||||
let _ = VirtualDom::new(Parent);
|
||||
}
|
||||
|
||||
fn Parent(cx: Scope, _props: &()) -> Element {
|
||||
fn Parent(cx: Scope<()>) -> Element {
|
||||
let value = cx.use_hook(|_| String::new(), |f| f);
|
||||
|
||||
cx.render(rsx! {
|
||||
@@ -25,11 +25,11 @@ struct ChildProps<'a> {
|
||||
name: &'a str,
|
||||
}
|
||||
|
||||
fn Child(cx: Scope, props: &ChildProps) -> Element {
|
||||
fn Child<'a>(cx: Scope<'a, ChildProps<'a>>) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
h1 { "it's nested" }
|
||||
Child2 { name: props.name }
|
||||
Child2 { name: cx.props.name }
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -39,8 +39,8 @@ struct Grandchild<'a> {
|
||||
name: &'a str,
|
||||
}
|
||||
|
||||
fn Child2(cx: Scope, props: &Grandchild) -> Element {
|
||||
fn Child2<'a>(cx: Scope<'a, Grandchild<'a>>) -> Element {
|
||||
cx.render(rsx! {
|
||||
div { "Hello {props.name}!" }
|
||||
div { "Hello {cx.props.name}!" }
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user