Remove lower case components that use the paran syntax (#551)

* chore: remove lowercase components

* chore: add docs are lowercase components

* docs: also add docs around lowercase components in current scope
This commit is contained in:
Jon Kelley authored and GitHub committed 2022-09-12 20:01:03 -07:00
1 parent d4d5d2733e
commit 38e8745db9
5 files changed
+56 -46

No files matched your search

+29 -29
View File
@@ -34,17 +34,17 @@ fn test_memory_leak() {
cx.render(rsx!(
div { "Hello, world!" }
child()
child()
child()
child()
child()
child()
borrowed_child(na: name)
borrowed_child(na: name)
borrowed_child(na: name)
borrowed_child(na: name)
borrowed_child(na: name)
Child {}
Child {}
Child {}
Child {}
Child {}
Child {}
BorrowedChild { na: name }
BorrowedChild { na: name }
BorrowedChild { na: name }
BorrowedChild { na: name }
BorrowedChild { na: name }
))
}
@@ -53,15 +53,15 @@ fn test_memory_leak() {
na: &'a str,
}
fn borrowed_child<'a>(cx: Scope<'a, BorrowedProps<'a>>) -> Element {
fn BorrowedChild<'a>(cx: Scope<'a, BorrowedProps<'a>>) -> Element {
rsx!(cx, div {
"goodbye {cx.props.na}"
child()
child()
Child {}
Child {}
})
}
fn child(cx: Scope) -> Element {
fn Child(cx: Scope) -> Element {
rsx!(cx, div { "goodbye world" })
}
@@ -91,7 +91,7 @@ fn memo_works_properly() {
cx.render(rsx!(
div { "Hello, world! {name}" }
child(na: "asdfg".to_string() )
Child { na: "asdfg".to_string() }
))
}
@@ -100,7 +100,7 @@ fn memo_works_properly() {
na: String,
}
fn child(cx: Scope<ChildProps>) -> Element {
fn Child(cx: Scope<ChildProps>) -> Element {
rsx!(cx, div { "goodbye world" })
}
@@ -120,10 +120,10 @@ fn memo_works_properly() {
fn free_works_on_root_props() {
fn app(cx: Scope<Custom>) -> Element {
cx.render(rsx! {
child(a: "alpha")
child(a: "beta")
child(a: "gamma")
child(a: "delta")
Child { a: "alpha"}
Child { a: "beta"}
Child { a: "gamma"}
Child { a: "delta"}
})
}
@@ -132,7 +132,7 @@ fn free_works_on_root_props() {
a: &'static str,
}
fn child(cx: Scope<ChildProps>) -> Element {
fn Child(cx: Scope<ChildProps>) -> Element {
rsx!(cx, "child {cx.props.a}")
}
@@ -154,7 +154,7 @@ fn free_works_on_root_props() {
fn free_works_on_borrowed() {
fn app(cx: Scope) -> Element {
cx.render(rsx! {
child(a: "alpha", b: "asd".to_string())
Child { a: "alpha", b: "asd".to_string() }
})
}
#[derive(Props)]
@@ -163,7 +163,7 @@ fn free_works_on_borrowed() {
b: String,
}
fn child<'a>(cx: Scope<'a, ChildProps<'a>>) -> Element {
fn Child<'a>(cx: Scope<'a, ChildProps<'a>>) -> Element {
dbg!("rendering child");
rsx!(cx, "child {cx.props.a}, {cx.props.b}")
}
@@ -208,9 +208,9 @@ fn old_props_arent_stale() {
*cnt += 1;
if *cnt == 1 {
rsx!(cx, div { child(a: "abcdef".to_string()) })
rsx!(cx, div { Child { a: "abcdef".to_string() } })
} else {
rsx!(cx, div { child(a: "abcdef".to_string()) })
rsx!(cx, div { Child { a: "abcdef".to_string() } })
}
}
@@ -218,7 +218,7 @@ fn old_props_arent_stale() {
struct ChildProps {
a: String,
}
fn child(cx: Scope<ChildProps>) -> Element {
fn Child(cx: Scope<ChildProps>) -> Element {
dbg!("rendering child", &cx.props.a);
rsx!(cx, div { "child {cx.props.a}" })
}
@@ -251,7 +251,7 @@ fn old_props_arent_stale() {
fn basic() {
fn app(cx: Scope) -> Element {
rsx!(cx, div {
child(a: "abcdef".to_string())
Child { a: "abcdef".to_string() }
})
}
@@ -260,7 +260,7 @@ fn basic() {
a: String,
}
fn child(cx: Scope<ChildProps>) -> Element {
fn Child(cx: Scope<ChildProps>) -> Element {
dbg!("rendering child", &cx.props.a);
rsx!(cx, div { "child {cx.props.a}" })
}
+2 -5
View File
@@ -74,17 +74,14 @@ impl Parse for BodyNode {
//
// example
// Div {}
// Div ()
// ::Div {}
// crate::Div {}
// component()
// component {} <-- already handled by elements
// ::component {}
// ::component ()
// crate::component{}
// crate::component()
// Input::<InputProps<'_, i32> {}
// crate::Input::<InputProps<'_, i32> {}
if body_stream.peek(token::Brace) || body_stream.peek(token::Paren) {
if body_stream.peek(token::Brace) {
Component::validate_component_path(&path)?;
return Ok(BodyNode::Component(stream.parse()?));
+2 -2
View File
@@ -13,7 +13,7 @@ fn app(cx: Scope) -> Element {
h2 { "thing 2"}
"asd"
"asd"
bapp()
Bapp {}
}
(0..10).map(|f| rsx!{
div {
@@ -23,7 +23,7 @@ fn app(cx: Scope) -> Element {
})
}
fn bapp(cx: Scope) -> Element {
fn Bapp(cx: Scope) -> Element {
cx.render(rsx! {
div {
h1 { "thing 1" }