File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed
packages/gitbook/src/components/Insights Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff 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
6464interface InsightsProviderProps extends InsightsEventContext {
6565 enabled : boolean ;
@@ -217,12 +217,7 @@ export function InsightsProvider(props: InsightsProviderProps) {
217217 * Get a callback to track an event.
218218 */
219219export 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/**
You can’t perform that action at this time.
0 commit comments