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
@@ -23,7 +23,7 @@ criterion_group!(mbenches, create_rows);
criterion_main!(mbenches);
fn create_rows(c: &mut Criterion) {
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);
+1 -1
View File
@@ -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);
+6 -6
View File
@@ -467,7 +467,7 @@ impl ScopeState {
/// # Example
///
/// ```rust, ignore
/// let mut dom = VirtualDom::new(|cx, props|cx.render(rsx!{ div {} }));
/// let mut dom = VirtualDom::new(|cx| cx.render(rsx!{ div {} }));
/// dom.rebuild();
///
/// let base = dom.base_scope();
@@ -511,7 +511,7 @@ impl ScopeState {
/// # Example
///
/// ```rust, ignore
/// let mut dom = VirtualDom::new(|cx, props| cx.render(rsx!{ div {} }));
/// let mut dom = VirtualDom::new(|cx| cx.render(rsx!{ div {} }));
/// dom.rebuild();
///
/// let base = dom.base_scope();
@@ -531,7 +531,7 @@ impl ScopeState {
/// # Example
///
/// ```rust, ignore
/// let mut dom = VirtualDom::new(|cx, props| cx.render(rsx!{ div {} }));
/// let mut dom = VirtualDom::new(|cx| cx.render(rsx!{ div {} }));
/// dom.rebuild();
///
/// let base = dom.base_scope();
@@ -550,7 +550,7 @@ impl ScopeState {
/// # Example
///
/// ```rust, ignore
/// let mut dom = VirtualDom::new(|cx, props| cx.render(rsx!{ div {} }));
/// let mut dom = VirtualDom::new(|cx| cx.render(rsx!{ div {} }));
/// dom.rebuild();
/// let base = dom.base_scope();
///
@@ -619,12 +619,12 @@ impl ScopeState {
/// ```rust, ignore
/// struct SharedState(&'static str);
///
/// static App: Component<()> = |cx, props|{
/// static App: Component = |cx| {
/// cx.use_hook(|_| cx.provide_context(SharedState("world")), |_| {}, |_| {});
/// rsx!(cx, Child {})
/// }
///
/// static Child: Component<()> = |cx| {
/// static Child: Component = |cx| {
/// let state = cx.consume_state::<SharedState>();
/// rsx!(cx, div { "hello {state.0}" })
/// }
+3 -3
View File
@@ -135,7 +135,7 @@ impl VirtualDom {
/// ```
///
/// Note: the VirtualDom is not progressed, you must either "run_with_deadline" or use "rebuild" to progress it.
pub fn new(root: Component<()>) -> Self {
pub fn new(root: Component) -> Self {
Self::new_with_props(root, ())
}
@@ -468,7 +468,7 @@ impl VirtualDom {
///
/// # Example
/// ```rust, ignore
/// static App: Component<()> = |cx, props| cx.render(rsx!{ "hello world" });
/// static App: Component = |cx| cx.render(rsx!{ "hello world" });
/// let mut dom = VirtualDom::new();
/// let edits = dom.rebuild();
///
@@ -505,7 +505,7 @@ impl VirtualDom {
/// value: Shared<&'static str>,
/// }
///
/// static App: Component<AppProps> = |cx, props|{
/// static App: Component<AppProps> = |cx| {
/// let val = cx.value.borrow();
/// cx.render(rsx! { div { "{val}" } })
/// };
+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"}