From d44335ee8b24806b39878829bc682dabeee57cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 23 Dec 2024 14:44:44 +0100 Subject: [PATCH] Fix PDF export crashing --- .../gitbook/src/components/Insights/InsightsProvider.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/gitbook/src/components/Insights/InsightsProvider.tsx b/packages/gitbook/src/components/Insights/InsightsProvider.tsx index f26b88b5c8..bfa80e0e39 100644 --- a/packages/gitbook/src/components/Insights/InsightsProvider.tsx +++ b/packages/gitbook/src/components/Insights/InsightsProvider.tsx @@ -59,7 +59,7 @@ type TrackEventCallback = ( options?: InsightsEventOptions, ) => void; -const InsightsContext = React.createContext(null); +const InsightsContext = React.createContext(() => {}); interface InsightsProviderProps extends InsightsEventContext { enabled: boolean; @@ -217,12 +217,7 @@ export function InsightsProvider(props: InsightsProviderProps) { * Get a callback to track an event. */ export function useTrackEvent(): TrackEventCallback { - const trackEvent = React.useContext(InsightsContext); - if (!trackEvent) { - throw new Error('useTrackEvent must be used within an InsightsProvider'); - } - - return trackEvent; + return React.useContext(InsightsContext); } /**