Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PDF export crashing #2661

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading