Skip to content

Commit 210c432

Browse files
authored
Fix PDF export crashing (#2661)
1 parent f92e906 commit 210c432

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/gitbook/src/components/Insights/InsightsProvider.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type TrackEventCallback = <EventName extends SiteEventName>(
5959
options?: InsightsEventOptions,
6060
) => void;
6161

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

6464
interface InsightsProviderProps extends InsightsEventContext {
6565
enabled: boolean;
@@ -217,12 +217,7 @@ export function InsightsProvider(props: InsightsProviderProps) {
217217
* Get a callback to track an event.
218218
*/
219219
export function useTrackEvent(): TrackEventCallback {
220-
const trackEvent = React.useContext(InsightsContext);
221-
if (!trackEvent) {
222-
throw new Error('useTrackEvent must be used within an InsightsProvider');
223-
}
224-
225-
return trackEvent;
220+
return React.useContext(InsightsContext);
226221
}
227222

228223
/**

0 commit comments

Comments
 (0)