From 9e7615b3f38d63917d64fcfcb321d9e400b556a1 Mon Sep 17 00:00:00 2001 From: Homyee King Date: Tue, 29 Oct 2024 20:22:12 +0800 Subject: [PATCH] feat: onbeforehydrate (#7001) --- packages/runtime/src/runClientApp.tsx | 3 +++ packages/runtime/src/types.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/runtime/src/runClientApp.tsx b/packages/runtime/src/runClientApp.tsx index d354be4210..f268cb0d2e 100644 --- a/packages/runtime/src/runClientApp.tsx +++ b/packages/runtime/src/runClientApp.tsx @@ -120,6 +120,9 @@ export default async function runClientApp(options: RunClientAppOptions) { reportRecoverableError(error, errorInfo, { ignoreRuntimeWarning: revalidate }); }), }; + if (appConfig?.app?.onBeforeHydrate) { + appConfig?.app?.onBeforeHydrate(); + } return ReactDOM.hydrateRoot(container, element, hydrateOptions); }); } diff --git a/packages/runtime/src/types.ts b/packages/runtime/src/types.ts index 08e659e063..80f2adeeee 100644 --- a/packages/runtime/src/types.ts +++ b/packages/runtime/src/types.ts @@ -17,6 +17,7 @@ type App = Partial<{ strict: boolean; errorBoundary: boolean; onRecoverableError: (error: unknown, errorInfo: ErrorStack) => void; + onBeforeHydrate: () => void; } & Record>; export interface ErrorStack {