fix: readme and examples syntax

This commit is contained in:
Jonathan Kelley committed 2021-12-28 23:48:25 -05:00
1 parent f24aae8787
commit 3dc0e59876
102 files changed
+213 -1222

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ fn new_dom<P: 'static + Send>(app: Component<P>, props: P) -> VirtualDom {
/// In debug, this should also toss a warning.
#[test]
fn test_early_abort() {
const app: Component<()> = |cx| {
const app: Component = |cx| {
let val = cx.use_hook(|_| 0, |f| f);
*val += 1;
+8 -8
View File
@@ -45,7 +45,7 @@ fn manual_diffing() {
#[test]
fn events_generate() {
static App: Component<()> = |cx| {
static App: Component = |cx| {
let count = cx.use_hook(|_| 0, |f| f);
let inner = match *count {
@@ -104,7 +104,7 @@ fn events_generate() {
#[test]
fn components_generate() {
static App: Component<()> = |cx| {
static App: Component = |cx| {
let render_phase = cx.use_hook(|_| 0, |f| f);
*render_phase += 1;
@@ -121,7 +121,7 @@ fn components_generate() {
})
};
static Child: Component<()> = |cx| {
static Child: Component = |cx| {
cx.render(rsx! {
h1 {}
})
@@ -220,7 +220,7 @@ fn components_generate() {
#[test]
fn component_swap() {
static App: Component<()> = |cx| {
static App: Component = |cx| {
let render_phase = cx.use_hook(|_| 0, |f| f);
*render_phase += 1;
@@ -259,7 +259,7 @@ fn component_swap() {
})
};
static NavBar: Component<()> = |cx| {
static NavBar: Component = |cx| {
println!("running navbar");
cx.render(rsx! {
h1 {
@@ -269,7 +269,7 @@ fn component_swap() {
})
};
static NavLink: Component<()> = |cx| {
static NavLink: Component = |cx| {
println!("running navlink");
cx.render(rsx! {
h1 {
@@ -278,7 +278,7 @@ fn component_swap() {
})
};
static Dashboard: Component<()> = |cx| {
static Dashboard: Component = |cx| {
println!("running dashboard");
cx.render(rsx! {
div {
@@ -287,7 +287,7 @@ fn component_swap() {
})
};
static Results: Component<()> = |cx| {
static Results: Component = |cx| {
println!("running results");
cx.render(rsx! {
div {
+2 -2
View File
@@ -13,12 +13,12 @@ mod test_logging;
fn shared_state_test() {
struct MySharedState(&'static str);
static App: Component<()> = |cx| {
static App: Component = |cx| {
cx.provide_context(MySharedState("world!"));
cx.render(rsx!(Child {}))
};
static Child: Component<()> = |cx| {
static Child: Component = |cx| {
let shared = cx.consume_context::<MySharedState>()?;
cx.render(rsx!("Hello, {shared.0}"))
};
+6 -6
View File
@@ -19,7 +19,7 @@ use DomEdit::*;
#[test]
fn app_runs() {
static App: Component<()> = |cx| rsx!(cx, div{"hello"} );
static App: Component = |cx| rsx!(cx, div{"hello"} );
let mut vdom = VirtualDom::new(App);
let edits = vdom.rebuild();
@@ -27,7 +27,7 @@ fn app_runs() {
#[test]
fn fragments_work() {
static App: Component<()> = |cx| {
static App: Component = |cx| {
cx.render(rsx!(
div{"hello"}
div{"goodbye"}
@@ -41,7 +41,7 @@ fn fragments_work() {
#[test]
fn lists_work() {
static App: Component<()> = |cx| {
static App: Component = |cx| {
cx.render(rsx!(
h1 {"hello"}
{(0..6).map(|f| rsx!(span{ "{f}" }))}
@@ -54,7 +54,7 @@ fn lists_work() {
#[test]
fn conditional_rendering() {
static App: Component<()> = |cx| {
static App: Component = |cx| {
cx.render(rsx!(
h1 {"hello"}
{true.then(|| rsx!(span{ "a" }))}
@@ -87,13 +87,13 @@ fn conditional_rendering() {
#[test]
fn child_components() {
static App: Component<()> = |cx| {
static App: Component = |cx| {
cx.render(rsx!(
{true.then(|| rsx!(Child { }))}
{false.then(|| rsx!(Child { }))}
))
};
static Child: Component<()> = |cx| {
static Child: Component = |cx| {
cx.render(rsx!(
h1 {"hello"}
h1 {"goodbye"}