diff --git a/examples/error_boundary/Cargo.toml b/examples/error_boundary/Cargo.toml new file mode 100644 index 000000000..6c317ac15 --- /dev/null +++ b/examples/error_boundary/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "error_boundary" +version = "0.1.0" +edition = "2021" + +[dependencies] +leptos = { path = "../../leptos" } +console_log = "0.2" +log = "0.4" +console_error_panic_hook = "0.1.7" diff --git a/examples/error_boundary/Makefile.toml b/examples/error_boundary/Makefile.toml new file mode 100644 index 000000000..ab9175602 --- /dev/null +++ b/examples/error_boundary/Makefile.toml @@ -0,0 +1,9 @@ +[tasks.build] +command = "cargo" +args = ["+nightly", "build-all-features"] +install_crate = "cargo-all-features" + +[tasks.check] +command = "cargo" +args = ["+nightly", "check-all-features"] +install_crate = "cargo-all-features" diff --git a/examples/error_boundary/README.md b/examples/error_boundary/README.md new file mode 100644 index 000000000..db9a91095 --- /dev/null +++ b/examples/error_boundary/README.md @@ -0,0 +1,7 @@ +# Leptos `` Example + +This example shows how to handle basic errors using Leptos. + +To run it, just issue the `trunk serve --open` command in the example root. This will build the app, run it, and open a new browser to serve it. + +> If you don't have `trunk` installed, [click here for install instructions.](https://trunkrs.dev/) diff --git a/examples/error_boundary/index.html b/examples/error_boundary/index.html new file mode 100644 index 000000000..75fa1f12a --- /dev/null +++ b/examples/error_boundary/index.html @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/examples/error_boundary/public/favicon.ico b/examples/error_boundary/public/favicon.ico new file mode 100644 index 000000000..2ba8527cb Binary files /dev/null and b/examples/error_boundary/public/favicon.ico differ diff --git a/examples/error_boundary/src/lib.rs b/examples/error_boundary/src/lib.rs new file mode 100644 index 000000000..3b3a82e04 --- /dev/null +++ b/examples/error_boundary/src/lib.rs @@ -0,0 +1,48 @@ +use leptos::*; + +#[component] +pub fn App(cx: Scope) -> impl IntoView { + let (value, set_value) = create_signal(cx, Ok(0)); + + // when input changes, try to parse a number from the input + let on_input = move |ev| set_value(event_target_value(&ev).parse::()); + + view! { cx, +

"Error Handling"

+ + } +} diff --git a/examples/error_boundary/src/main.rs b/examples/error_boundary/src/main.rs new file mode 100644 index 000000000..efe256fcb --- /dev/null +++ b/examples/error_boundary/src/main.rs @@ -0,0 +1,12 @@ +use error_boundary::*; +use leptos::*; + +pub fn main() { + _ = console_log::init_with_level(log::Level::Debug); + console_error_panic_hook::set_once(); + mount_to_body(|cx| { + view! { cx, + + } + }) +}