mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 08:44:28 -05:00
examples: fix input type so tests work, and update text to make the purpose clearer
This commit is contained in:
@@ -7,13 +7,14 @@ pub fn App() -> impl IntoView {
|
||||
view! {
|
||||
<h1>"Error Handling"</h1>
|
||||
<label>
|
||||
"Type a number (or something that's not a number!)"
|
||||
"Type an integer (or something that's not an integer!)"
|
||||
<input
|
||||
type="text"
|
||||
type="number"
|
||||
value=move || value.get().unwrap_or_default()
|
||||
// when input changes, try to parse a number from the input
|
||||
on:input:target=move |ev| set_value.set(ev.target().value().parse::<i32>())
|
||||
/> // If an `Err(_) has been rendered inside the <ErrorBoundary/>,
|
||||
/>
|
||||
// If an `Err(_) has been rendered inside the <ErrorBoundary/>,
|
||||
// the fallback will be displayed. Otherwise, the children of the
|
||||
// <ErrorBoundary/> will be displayed.
|
||||
// the fallback receives a signal containing current errors
|
||||
@@ -21,7 +22,7 @@ pub fn App() -> impl IntoView {
|
||||
let errors = errors.clone();
|
||||
view! {
|
||||
<div class="error">
|
||||
<p>"Not a number! Errors: "</p>
|
||||
<p>"Not an integer! Errors: "</p>
|
||||
// we can render a list of errors
|
||||
// as strings, if we'd like
|
||||
<ul>
|
||||
@@ -39,9 +40,10 @@ pub fn App() -> impl IntoView {
|
||||
}>
|
||||
|
||||
<p>
|
||||
"You entered "
|
||||
// because `value` is `Result<i32, _>`,
|
||||
// it will render the `i32` if it is `Ok`,
|
||||
"You entered " // and render nothing and trigger the error boundary
|
||||
// and render nothing and trigger the error boundary
|
||||
// if it is `Err`. It's a signal, so this will dynamically
|
||||
// update when `value` changes
|
||||
<strong>{value}</strong>
|
||||
|
||||
Reference in New Issue
Block a user