From d4247d25f1fa65fb98e6fcfba5d79868c5c993c1 Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Wed, 8 Apr 2026 18:47:56 +0200 Subject: [PATCH] Typecheck --- .../components/Embeddable/EmbeddableAIChat.tsx | 2 +- .../Embeddable/EmbeddableAIContextProvider.tsx | 2 +- .../Embeddable/EmbeddableIframeAPI.tsx | 16 +++++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx b/packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx index ae63adc8e..d55e5582e 100644 --- a/packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx +++ b/packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx @@ -43,7 +43,7 @@ export function EmbeddableAIChat(props: EmbeddableAIChatProps) { const chat = useAIChatState(); const { config: siteConfig } = useAI(); const chatController = useAIChatController(); - const embedConfig = useEmbeddableConfiguration(); + const embedConfig = useEmbeddableConfiguration((state) => state); const language = useLanguage(); React.useEffect(() => { diff --git a/packages/gitbook/src/components/Embeddable/EmbeddableAIContextProvider.tsx b/packages/gitbook/src/components/Embeddable/EmbeddableAIContextProvider.tsx index ba26bcf58..56b4c69fa 100644 --- a/packages/gitbook/src/components/Embeddable/EmbeddableAIContextProvider.tsx +++ b/packages/gitbook/src/components/Embeddable/EmbeddableAIContextProvider.tsx @@ -12,7 +12,7 @@ type EmbeddableAIContextProviderProps = PropsWithChildren; */ export function EmbeddableAIContextProvider(props: EmbeddableAIContextProviderProps) { const { aiMode, suggestions, greeting, trademark, children } = props; - const embedConfig = useEmbeddableConfiguration(); + const embedConfig = useEmbeddableConfiguration((state) => state); return ( ( - fn: (state: GitBookEmbeddableConfiguration) => T = (state) => state -) { - return useStore(embeddableConfiguration, fn); +/** Subscribe to embed configuration from the parent (Zustand). */ +export function useEmbeddableConfiguration( + selector: (state: GitBookEmbeddableConfiguration) => T, +): T { + return useStore(embeddableConfiguration, selector); } /** @@ -161,7 +159,7 @@ export function EmbeddableIframeTabs(props: { siteTitle: string; }) { const { ref, active = 'assistant', baseURL, siteTitle } = props; - const { tabs: configuredTabs, actions } = useEmbeddableConfiguration(); + const { tabs: configuredTabs, actions } = useEmbeddableConfiguration((state) => state); const { assistants, config } = useAI(); @@ -233,7 +231,7 @@ export function EmbeddableIframeTabs(props: { } export function EmbeddableIframeCloseButton() { - const { closeButton } = useEmbeddableConfiguration(); + const { closeButton } = useEmbeddableConfiguration((state) => state); if (!closeButton) { return null;