Skip to content

Commit

Permalink
fix: move skip check
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjd authored and simoneb committed Jan 7, 2025
1 parent c76c315 commit db10fdf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/graphql-hooks/src/useSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ function useSubscription<
const contextClient = useContext(ClientContext)
const client = options.client || contextClient

if (options.skip) {
return
}

if (!client) {
throw new Error(
'useSubscription() requires a client to be passed in the options or as a context value'
)
}

useDeepCompareEffect(() => {
if (options.skip) {
return
}

const request = {
query: options.query,
variables: options.variables
Expand All @@ -55,7 +55,7 @@ function useSubscription<
return () => {
subscription.unsubscribe()
}
}, [options.query, options.variables])
}, [options.query, options.variables, options.skip])
}

export default useSubscription

0 comments on commit db10fdf

Please sign in to comment.