feat: add an unhygenic render macro (#556)
* feat: add an unhygenic render macro * chore: use render instead of rsx!(cx,
This commit is contained in:
1 parent
0c48cb3601
commit
28fba42e7e
28 files changed
+158
-163
No files matched your search
@@ -23,7 +23,7 @@ fn create_rows(c: &mut Criterion) {
|
||||
static App: Component = |cx| {
|
||||
let mut rng = SmallRng::from_entropy();
|
||||
|
||||
rsx!(cx, table {
|
||||
render!(table {
|
||||
tbody {
|
||||
(0..10_000_usize).map(|f| {
|
||||
let label = Label::new(&mut rng);
|
||||
|
||||
@@ -26,7 +26,7 @@ pub mod prelude {
|
||||
pub use dioxus_core::prelude::*;
|
||||
|
||||
#[cfg(feature = "macro")]
|
||||
pub use dioxus_core_macro::{format_args_f, inline_props, rsx, Props};
|
||||
pub use dioxus_core_macro::{format_args_f, inline_props, render, rsx, Props};
|
||||
|
||||
#[cfg(feature = "html")]
|
||||
pub use dioxus_html as dioxus_elements;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn new_dom() -> VirtualDom {
|
||||
VirtualDom::new(|cx| rsx!(cx, "hi"))
|
||||
VirtualDom::new(|cx| render!("hi"))
|
||||
}
|
||||
|
||||
use dioxus_core::DomEdit::*;
|
||||
|
||||
@@ -28,7 +28,7 @@ fn test_early_abort() {
|
||||
return None;
|
||||
}
|
||||
|
||||
rsx!(cx, div { "Hello, world!" })
|
||||
render!(div { "Hello, world!" })
|
||||
};
|
||||
|
||||
let mut dom = new_dom(app, ());
|
||||
|
||||
@@ -54,7 +54,7 @@ fn test_memory_leak() {
|
||||
}
|
||||
|
||||
fn BorrowedChild<'a>(cx: Scope<'a, BorrowedProps<'a>>) -> Element {
|
||||
rsx!(cx, div {
|
||||
render!(div {
|
||||
"goodbye {cx.props.na}"
|
||||
Child {}
|
||||
Child {}
|
||||
@@ -62,7 +62,7 @@ fn test_memory_leak() {
|
||||
}
|
||||
|
||||
fn Child(cx: Scope) -> Element {
|
||||
rsx!(cx, div { "goodbye world" })
|
||||
render!(div { "goodbye world" })
|
||||
}
|
||||
|
||||
let mut dom = new_dom(app, ());
|
||||
@@ -101,7 +101,7 @@ fn memo_works_properly() {
|
||||
}
|
||||
|
||||
fn Child(cx: Scope<ChildProps>) -> Element {
|
||||
rsx!(cx, div { "goodbye world" })
|
||||
render!(div { "goodbye world" })
|
||||
}
|
||||
|
||||
let mut dom = new_dom(app, ());
|
||||
@@ -133,7 +133,7 @@ fn free_works_on_root_props() {
|
||||
}
|
||||
|
||||
fn Child(cx: Scope<ChildProps>) -> Element {
|
||||
rsx!(cx, "child {cx.props.a}")
|
||||
render!("child {cx.props.a}")
|
||||
}
|
||||
|
||||
struct Custom {
|
||||
@@ -165,7 +165,7 @@ fn free_works_on_borrowed() {
|
||||
|
||||
fn Child<'a>(cx: Scope<'a, ChildProps<'a>>) -> Element {
|
||||
dbg!("rendering child");
|
||||
rsx!(cx, "child {cx.props.a}, {cx.props.b}")
|
||||
render!("child {cx.props.a}, {cx.props.b}")
|
||||
}
|
||||
|
||||
impl Drop for ChildProps<'_> {
|
||||
@@ -193,7 +193,7 @@ fn free_works_on_root_hooks() {
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
let name = cx.use_hook(|| Droppable(String::from("asd")));
|
||||
rsx!(cx, div { "{name.0}" })
|
||||
render!(div { "{name.0}" })
|
||||
}
|
||||
|
||||
let mut dom = new_dom(app, ());
|
||||
@@ -208,9 +208,9 @@ fn old_props_arent_stale() {
|
||||
*cnt += 1;
|
||||
|
||||
if *cnt == 1 {
|
||||
rsx!(cx, div { Child { a: "abcdef".to_string() } })
|
||||
render!(div { Child { a: "abcdef".to_string() } })
|
||||
} else {
|
||||
rsx!(cx, div { Child { a: "abcdef".to_string() } })
|
||||
render!(div { Child { a: "abcdef".to_string() } })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ fn old_props_arent_stale() {
|
||||
}
|
||||
fn Child(cx: Scope<ChildProps>) -> Element {
|
||||
dbg!("rendering child", &cx.props.a);
|
||||
rsx!(cx, div { "child {cx.props.a}" })
|
||||
render!(div { "child {cx.props.a}" })
|
||||
}
|
||||
|
||||
let mut dom = new_dom(app, ());
|
||||
@@ -250,7 +250,7 @@ fn old_props_arent_stale() {
|
||||
#[test]
|
||||
fn basic() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
rsx!(cx, div {
|
||||
render!(div {
|
||||
Child { a: "abcdef".to_string() }
|
||||
})
|
||||
}
|
||||
@@ -262,7 +262,7 @@ fn basic() {
|
||||
|
||||
fn Child(cx: Scope<ChildProps>) -> Element {
|
||||
dbg!("rendering child", &cx.props.a);
|
||||
rsx!(cx, div { "child {cx.props.a}" })
|
||||
render!(div { "child {cx.props.a}" })
|
||||
}
|
||||
|
||||
let mut dom = new_dom(app, ());
|
||||
@@ -290,7 +290,7 @@ fn leak_thru_children() {
|
||||
|
||||
#[inline_props]
|
||||
fn Child(cx: Scope, name: String) -> Element {
|
||||
rsx!(cx, div { "child {name}" })
|
||||
render!(div { "child {name}" })
|
||||
}
|
||||
|
||||
let mut dom = new_dom(app, ());
|
||||
@@ -315,8 +315,7 @@ fn test_pass_thru() {
|
||||
}
|
||||
|
||||
fn NavMenu(cx: Scope) -> Element {
|
||||
rsx!(cx,
|
||||
NavBrand {}
|
||||
render!( NavBrand {}
|
||||
div {
|
||||
NavStart {}
|
||||
NavEnd {}
|
||||
@@ -325,15 +324,15 @@ fn test_pass_thru() {
|
||||
}
|
||||
|
||||
fn NavBrand(cx: Scope) -> Element {
|
||||
rsx!(cx, div {})
|
||||
render!(div {})
|
||||
}
|
||||
|
||||
fn NavStart(cx: Scope) -> Element {
|
||||
rsx!(cx, div {})
|
||||
render!(div {})
|
||||
}
|
||||
|
||||
fn NavEnd(cx: Scope) -> Element {
|
||||
rsx!(cx, div {})
|
||||
render!(div {})
|
||||
}
|
||||
|
||||
#[inline_props]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn new_dom() -> VirtualDom {
|
||||
VirtualDom::new(|cx| rsx!(cx, "hi"))
|
||||
VirtualDom::new(|cx| render!("hi"))
|
||||
}
|
||||
|
||||
use dioxus_core::DomEdit::*;
|
||||
|
||||
@@ -15,7 +15,7 @@ use dioxus_core::DomEdit::*;
|
||||
|
||||
#[test]
|
||||
fn app_runs() {
|
||||
static App: Component = |cx| rsx!(cx, div{"hello"} );
|
||||
static App: Component = |cx| render!(div{"hello"} );
|
||||
|
||||
let mut vdom = VirtualDom::new(App);
|
||||
let edits = vdom.rebuild();
|
||||
|
||||
Reference in new issue
Block a user