11import { useCallback , useMemo } from 'react' ;
22
33import { eventMethodCalled } from '../../telemetry/events' ;
4- import type { BillingSubscriptionResource , EnvironmentResource } from '../../types' ;
4+ import type { EnvironmentResource } from '../../types' ;
55import { useClerkQueryClient } from '../clerk-rq/use-clerk-query-client' ;
66import { useClerkQuery } from '../clerk-rq/useQuery' ;
77import {
@@ -15,11 +15,12 @@ import type { SubscriptionResult, UseSubscriptionParams } from './useSubscriptio
1515const hookName = 'useSubscription' ;
1616
1717/**
18- * @internal
1918 * This is the new implementation of useSubscription using React Query.
2019 * It is exported only if the package is build with the `CLERK_USE_RQ` environment variable set to `true`.
20+ *
21+ * @internal
2122 */
22- export function useSubscription ( params ?: UseSubscriptionParams ) : SubscriptionResult < BillingSubscriptionResource > {
23+ export function useSubscription ( params ?: UseSubscriptionParams ) : SubscriptionResult {
2324 useAssertWrappedByClerkProvider ( hookName ) ;
2425
2526 const clerk = useClerkInstanceContext ( ) ;
@@ -62,7 +63,9 @@ export function useSubscription(params?: UseSubscriptionParams): SubscriptionRes
6263
6364 return {
6465 data : query . data ,
65- error : query . error ,
66+ // Our existing types for SWR return undefined when there is no error, but React Query returns null.
67+ // So we need to convert the error to undefined, for backwards compatibility.
68+ error : query . error ?? undefined ,
6669 isLoading : query . isLoading ,
6770 isFetching : query . isFetching ,
6871 revalidate,
0 commit comments