fix: `<ErrorBoundary/>` IDs with new hydration key system (#1180)

This commit is contained in:
Greg Johnston 2023-06-13 18:38:23 -04:00 committed by GitHub
parent 2b7923261b
commit a98885a123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,5 @@
use crate::Children;
use leptos_dom::{Errors, IntoView};
use leptos_dom::{Errors, HydrationCtx, IntoView};
use leptos_macro::{component, view};
use leptos_reactive::{
create_rw_signal, provide_context, signal_prelude::*, RwSignal, Scope,
@ -28,7 +28,7 @@ use leptos_reactive::{
/// }
/// # });
/// ```
#[component(transparent)]
#[component]
pub fn ErrorBoundary<F, IV>(
cx: Scope,
/// The components inside the tag which will get rendered
@ -40,6 +40,7 @@ where
F: Fn(Scope, RwSignal<Errors>) -> IV + 'static,
IV: IntoView,
{
_ = HydrationCtx::next_component();
let errors: RwSignal<Errors> = create_rw_signal(cx, Errors::default());
provide_context(cx, errors);

View File

@ -80,7 +80,7 @@ where
E: Error + Send + Sync + 'static,
{
fn into_view(self, cx: leptos_reactive::Scope) -> crate::View {
let id = ErrorKey(HydrationCtx::peek().id.to_string().into());
let id = ErrorKey(HydrationCtx::peek().fragment.to_string().into());
let errors = use_context::<RwSignal<Errors>>(cx);
match self {
Ok(stuff) => {