Skip to content

Commit

Permalink
Fix PDF export crashing (#2661)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyPesse authored Dec 23, 2024
1 parent f92e906 commit 210c432
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/gitbook/src/components/Insights/InsightsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type TrackEventCallback = <EventName extends SiteEventName>(
options?: InsightsEventOptions,
) => void;

const InsightsContext = React.createContext<TrackEventCallback | null>(null);
const InsightsContext = React.createContext<TrackEventCallback>(() => {});

interface InsightsProviderProps extends InsightsEventContext {
enabled: boolean;
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 210c432

Please sign in to comment.