-
Notifications
You must be signed in to change notification settings - Fork 425
feat(shared): Remove SWR #7568
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
base: main
Are you sure you want to change the base?
feat(shared): Remove SWR #7568
Conversation
🦋 Changeset detectedLatest commit: a488ba1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
!allow-major |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughRemoves SWR-based implementations and virtual data-hook shims across packages/shared and related packages, deletes the compile-time flag Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @packages/shared/src/react/billing/useInitializePaymentMethod.tsx:
- Around line 22-74: Call useClearQueriesOnSignOut to purge the cached
initializePaymentMethod result on sign-out: import useClearQueriesOnSignOut and
invoke it in useInitializePaymentMethod (after you compute queryKey / query)
with isSignedOut: user === null, authenticated: the authenticated value from
useUserContext (or equivalent boolean available from user context), and
stableKeys: queryKey (or the stableKey used by other billing hooks). This
ensures the sensitive externalClientSecret in initializedPaymentMethod is
removed from the query cache on sign-out.
In @packages/shared/src/react/hooks/usePagesOrInfinite.tsx:
- Around line 201-208: The non-infinite pagination logic multiplies offsetCount
twice, producing wrong results when initialPageRef.current > 1; update the
hasNextPage and hasPreviousPage conditions to stop multiplying offsetCount by
pageSizeRef.current again: when not triggerInfinite, set hasNextPage to count -
offsetCount > page * pageSizeRef.current, and set hasPreviousPage to (page - 1)
* pageSizeRef.current > offsetCount; keep triggerInfinite branches using
infiniteQuery as-is and reference the symbols offsetCount, pageSizeRef.current,
initialPageRef.current, triggerInfinite, infiniteQuery, hasNextPage, and
hasPreviousPage when making the change.
📜 Review details
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (58)
.changeset/polite-cars-lose.md.changeset/remove-swr-switches.mdpackages/clerk-js/package.jsonpackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/global.d.tspackages/shared/package.jsonpackages/shared/src/react/billing/useInitializePaymentMethod.rq.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.swr.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/billing/useStripeClerkLibs.rq.tsxpackages/shared/src/react/billing/useStripeClerkLibs.swr.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/billing/useStripeLoader.rq.tsxpackages/shared/src/react/billing/useStripeLoader.swr.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/clerk-swr.tspackages/shared/src/react/contexts.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/index.tspackages/shared/src/react/hooks/useAPIKeys.swr.tsxpackages/shared/src/react/hooks/useAPIKeys.tspackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.rq.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.swr.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.rq.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.swr.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.rq.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.swr.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsxpackages/shared/src/react/hooks/useStatementQuery.rq.tsxpackages/shared/src/react/hooks/useStatementQuery.swr.tsxpackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/hooks/useSubscription.rq.tsxpackages/shared/src/react/hooks/useSubscription.swr.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/providers/SWRConfigCompat.rq.tsxpackages/shared/src/react/providers/SWRConfigCompat.swr.tsxpackages/shared/src/react/providers/SWRConfigCompat.tsxpackages/shared/src/types/virtual-data-hooks.d.tspackages/shared/tsconfig.jsonpackages/shared/tsdown.config.mtspackages/shared/vitest.config.mtspackages/shared/vitest.setup.mtspackages/ui/bundlewatch.config.jsonpackages/ui/package.jsonpackages/ui/src/contexts/CoreClerkContextWrapper.tsx
💤 Files with no reviewable changes (27)
- packages/shared/src/react/providers/SWRConfigCompat.tsx
- packages/shared/src/react/providers/SWRConfigCompat.swr.tsx
- packages/shared/src/react/hooks/usePaymentAttemptQuery.swr.tsx
- packages/shared/src/types/virtual-data-hooks.d.ts
- packages/shared/src/react/hooks/useAPIKeys.ts
- packages/shared/global.d.ts
- packages/shared/src/react/hooks/usePaymentAttemptQuery.rq.tsx
- packages/shared/src/react/hooks/useStatementQuery.swr.tsx
- packages/shared/src/react/billing/useStripeLoader.swr.tsx
- packages/shared/src/react/billing/useStripeLoader.rq.tsx
- packages/shared/src/react/hooks/useSubscription.rq.tsx
- packages/shared/vitest.setup.mts
- packages/shared/src/react/providers/SWRConfigCompat.rq.tsx
- packages/shared/src/react/hooks/usePlanDetailsQuery.rq.tsx
- packages/shared/src/react/billing/useInitializePaymentMethod.swr.tsx
- packages/shared/src/react/hooks/usePagesOrInfinite.swr.tsx
- packages/shared/src/react/hooks/usePagesOrInfinite.rq.tsx
- packages/shared/src/react/billing/useInitializePaymentMethod.rq.tsx
- packages/shared/src/react/hooks/useSubscription.swr.tsx
- packages/shared/vitest.config.mts
- packages/shared/src/react/hooks/usePlanDetailsQuery.swr.tsx
- packages/shared/src/react/clerk-swr.ts
- packages/shared/src/react/hooks/useStatementQuery.rq.tsx
- packages/shared/src/react/hooks/useAPIKeys.swr.tsx
- packages/shared/tsdown.config.mts
- packages/shared/src/react/billing/useStripeClerkLibs.swr.tsx
- packages/shared/src/react/billing/useStripeClerkLibs.rq.tsx
🧰 Additional context used
📓 Path-based instructions (19)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
All code must pass ESLint checks with the project's configuration
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/package.jsonpackages/ui/package.jsonpackages/ui/bundlewatch.config.jsonpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/tsconfig.jsonpackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/clerk-js/package.jsonpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Follow established naming conventions (PascalCase for components, camelCase for variables)
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
packages/**/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Implement type guards forunknowntypes using the patternfunction isType(value: unknown): value is Type
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details in classes
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like<T extends { id: string }>
Use utility types likeOmit,Partial, andPickfor data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Useconst assertionswithas constfor literal types
Usesatisfiesoperator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use ESLint with custom configurations tailored for different package types
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use Prettier for code formatting across all packages
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/package.jsonpackages/ui/package.jsonpackages/ui/bundlewatch.config.jsonpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/tsconfig.jsonpackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/clerk-js/package.jsonpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*
⚙️ CodeRabbit configuration file
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
**/*: Only comment on issues that would block merging, ignore minor or stylistic concerns.
Restrict feedback to errors, security risks, or functionality-breaking problems.
Do not post comments on code style, formatting, or non-critical improvements.
Keep reviews short: flag only issues that make the PR unsafe to merge.
Group similar issues into a single comment instead of posting multiple notes.
Skip repetition: if a pattern repeats, mention it once at a summary level only.
Do not add general suggestions, focus strictly on merge-blocking concerns.
If there are no critical problems, respond with minimal approval (e.g., 'Looks good'). Do not add additional review.
Avoid line-by-line commentary unless it highlights a critical bug or security hole.
Highlight only issues that could cause runtime errors, data loss, or severe maintainability issues.
Ignore minor optimization opportunities, focus solely on correctness and safety.
Provide a top-level summary of critical blockers rather than detailed per-line notes.
Comment only when the issue must be resolved before merge, otherwise remain silent.
When in doubt, err on the side of fewer comments, brevity and blocking issues only.
Avoid posting any refactoring issues.
Files:
packages/shared/src/react/hooks/useClearQueriesOnSignOut.tspackages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/package.jsonpackages/ui/package.jsonpackages/ui/bundlewatch.config.jsonpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/tsconfig.jsonpackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/index.tspackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/clerk-js/package.jsonpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features
Files:
packages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.tsx: Use error boundaries in React components
Minimize re-renders in React components
**/*.tsx: Use proper type definitions for props and state in React components
Leverage TypeScript's type inference where possible in React components
Use proper event types for handlers in React components
Implement proper generic types for reusable React components
Use proper type guards for conditional rendering in React components
Files:
packages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use real Clerk instances for integration tests
Files:
packages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.tspackages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.tspackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
**/*.{md,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Update documentation for API changes
Files:
packages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components (e.g.,UserProfile,NavigationMenu)
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Separate UI components from business logic components
Use useState for simple state management in React components
Use useReducer for complex state logic in React components
Implement proper state initialization in React components
Use proper state updates with callbacks in React components
Implement proper state cleanup in React components
Use Context API for theme/authentication state management
Implement proper state persistence in React applications
Use React.memo for expensive components
Implement proper useCallback for handlers in React components
Use proper useMemo for expensive computations in React components
Implement proper virtualization for lists in React components
Use proper code splitting with React.lazy in React applications
Implement proper cleanup in useEffect hooks
Use proper refs for DOM access in React components
Implement proper event listener cleanup in React components
Use proper abort controllers for fetch in React components
Implement proper subscription cleanup in React components
Use proper HTML elements for semantic HTML in React components
Implement proper ARIA attributes for accessibility in React components
Use proper heading hierarchy in React components
Implement proper form labels in React components
Use proper button types in React components
Implement proper focus management for keyboard navigation in React components
Use proper keyboard shortcuts in React components
Implement proper tab order in React components
Use proper ...
Files:
packages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/useOrganizationList.tsxpackages/shared/src/react/hooks/useStatementQuery.tsxpackages/shared/src/react/billing/useInitializePaymentMethod.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/clerk-js/src/test/create-fixtures.tsxpackages/shared/src/react/hooks/useAPIKeys.tsxpackages/shared/src/react/hooks/useOrganization.tsxpackages/shared/src/react/hooks/createBillingPaginatedHook.tsxpackages/shared/src/react/hooks/useSubscription.tsxpackages/shared/src/react/hooks/__tests__/wrapper.tsxpackages/shared/src/react/contexts.tsxpackages/shared/src/react/billing/useStripeLoader.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/billing/useStripeClerkLibs.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsxpackages/shared/src/react/hooks/usePaymentAttemptQuery.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/ui/src/contexts/CoreClerkContextWrapper.tsxpackages/shared/src/react/hooks/usePlanDetailsQuery.tsx
**/*.{test,spec}.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.{test,spec}.{jsx,tsx}: Use React Testing Library for unit testing React components
Test component behavior, not implementation details
Use proper test queries in React Testing Library tests
Implement proper test isolation in React component tests
Use proper test coverage in React component tests
Test component interactions in integration tests
Use proper test data in React component tests
Implement proper test setup in React component tests
Use proper test cleanup in React component tests
Implement proper test assertions in React component tests
Use proper test structure for React component tests
Files:
packages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsxpackages/shared/src/react/hooks/__tests__/usePlans.spec.tsxpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsxpackages/shared/src/react/hooks/__tests__/createBillingPaginatedHook.spec.tsx
packages/*/package.json
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/*/package.json: Packages should export TypeScript types alongside runtime code
Follow semantic versioning for all packagesAll packages must be published under @clerk namespace
packages/*/package.json: Framework packages should depend on@clerk/clerk-jsfor core functionality
@clerk/sharedshould be a common dependency for most packages in the monorepo
Files:
packages/shared/package.jsonpackages/ui/package.jsonpackages/clerk-js/package.json
**/package.json
📄 CodeRabbit inference engine (.cursor/rules/global.mdc)
Use pnpm as the package manager for this monorepo
Files:
packages/shared/package.jsonpackages/ui/package.jsonpackages/clerk-js/package.json
**/index.ts
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
Avoid barrel files (index.ts re-exports) as they can cause circular dependencies
Files:
packages/shared/src/react/hooks/index.ts
🧬 Code graph analysis (14)
packages/shared/src/react/hooks/useClearQueriesOnSignOut.ts (1)
packages/clerk-js/src/core/auth/AuthCookieService.ts (1)
isSignedOut(98-103)
packages/shared/src/react/hooks/useOrganizationList.tsx (2)
packages/react/src/isomorphicClerk.ts (1)
user(730-736)packages/shared/src/react/hooks/createCacheKeys.ts (1)
createCacheKeys(7-23)
packages/shared/src/react/hooks/__tests__/useClearQueriesOnSignOut.spec.ts (1)
packages/shared/src/react/hooks/useClearQueriesOnSignOut.ts (2)
withInfiniteKey(6-6)useClearQueriesOnSignOut(28-61)
packages/shared/src/react/billing/useInitializePaymentMethod.tsx (8)
packages/shared/src/types/billing.ts (2)
ForPayerType(89-89)BillingInitializedPaymentMethodResource(369-382)packages/shared/src/react/contexts.tsx (2)
useOrganizationContext(119-119)useUserContext(122-122)packages/shared/src/react/index.ts (2)
useOrganizationContext(15-15)useUserContext(18-18)packages/shared/src/react/hooks/useBillingHookEnabled.ts (1)
useBillingHookEnabled(7-27)packages/shared/src/react/clerk-rq/useQuery.ts (1)
useClerkQuery(39-41)packages/shared/src/react/clerk-rq/keep-previous-data.ts (1)
defineKeepPreviousDataFn(4-11)packages/shared/src/react/clerk-rq/use-clerk-query-client.ts (1)
useClerkQueryClient(84-84)packages/clerk-js/src/core/modules/billing/payment-source-methods.ts (1)
initializePaymentMethod(20-30)
packages/shared/src/react/hooks/__tests__/usePlans.spec.tsx (1)
packages/clerk-js/src/test/utils.ts (1)
waitFor(73-73)
packages/clerk-js/src/test/create-fixtures.tsx (2)
packages/ui/src/contexts/CoreClerkContextWrapper.tsx (1)
CoreClerkContextWrapper(21-67)packages/clerk-js/src/test/core-fixtures.ts (1)
clerkMock(249-256)
packages/shared/src/react/hooks/useAPIKeys.tsx (2)
packages/shared/src/react/hooks/createCacheKeys.ts (1)
createCacheKeys(7-23)packages/shared/src/react/stable-keys.ts (1)
STABLE_KEYS(30-51)
packages/shared/src/react/hooks/useOrganization.tsx (3)
packages/react/src/isomorphicClerk.ts (1)
organization(738-744)packages/shared/src/react/hooks/createCacheKeys.ts (1)
createCacheKeys(7-23)packages/shared/src/react/stable-keys.ts (1)
STABLE_KEYS(30-51)
packages/shared/src/react/hooks/createBillingPaginatedHook.tsx (1)
packages/react/src/isomorphicClerk.ts (1)
organization(738-744)
packages/shared/src/react/contexts.tsx (1)
packages/shared/src/react/index.ts (1)
OrganizationProvider(9-9)
packages/shared/src/react/billing/useStripeLoader.tsx (4)
packages/shared/src/react/billing/useStripeClerkLibs.tsx (1)
UseStripeClerkLibsResult(14-14)packages/shared/src/react/hooks/useBillingHookEnabled.ts (1)
useBillingHookEnabled(7-27)packages/shared/src/react/clerk-rq/useQuery.ts (1)
useClerkQuery(39-41)packages/shared/src/react/clerk-rq/keep-previous-data.ts (1)
defineKeepPreviousDataFn(4-11)
packages/shared/src/react/billing/useStripeClerkLibs.tsx (4)
packages/shared/src/react/hooks/index.ts (1)
useClerk(10-10)packages/shared/src/react/hooks/useBillingHookEnabled.ts (1)
useBillingHookEnabled(7-27)packages/shared/src/react/clerk-rq/useQuery.ts (1)
useClerkQuery(39-41)packages/shared/src/react/clerk-rq/keep-previous-data.ts (1)
defineKeepPreviousDataFn(4-11)
packages/ui/src/contexts/CoreClerkContextWrapper.tsx (1)
packages/shared/src/react/contexts.tsx (1)
OrganizationProvider(112-112)
packages/shared/src/react/hooks/usePlanDetailsQuery.tsx (7)
packages/shared/src/react/hooks/usePlanDetailsQuery.types.ts (2)
UsePlanDetailsQueryParams(7-28)PlanDetailsQueryResult(33-50)packages/shared/src/react/contexts.tsx (1)
useClerkInstanceContext(116-116)packages/shared/src/react/index.ts (1)
useClerkInstanceContext(12-12)packages/shared/src/react/hooks/usePlanDetailsQuery.shared.ts (1)
usePlanDetailsQueryCacheKeys(6-22)packages/shared/src/react/hooks/useBillingHookEnabled.ts (1)
useBillingHookEnabled(7-27)packages/shared/src/react/clerk-rq/useQuery.ts (1)
useClerkQuery(39-41)packages/shared/src/react/clerk-rq/keep-previous-data.ts (1)
defineKeepPreviousDataFn(4-11)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (28)
- GitHub Check: Unit Tests (shared, clerk-js, RQ)
- GitHub Check: Publish with pkg-pr-new
- GitHub Check: Unit Tests (**)
- GitHub Check: Integration Tests (billing, chrome, RQ)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (quickstart, chrome, 15)
- GitHub Check: Integration Tests (sessions:staging, chrome)
- GitHub Check: Integration Tests (quickstart, chrome, 16)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
- GitHub Check: Integration Tests (handshake, chrome)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (handshake:staging, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 16)
- GitHub Check: Integration Tests (machine, chrome)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (custom, chrome)
- GitHub Check: Integration Tests (machine, chrome, RQ)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (14)
.changeset/polite-cars-lose.md (1)
1-5: Changeset entry is well-formed and accurately documents the fix.The changeset correctly declares a patch bump for
@clerk/sharedwith a clear, concise description that accurately reflects theuseClearQueriesOnSignOuthook fix referenced in the PR objectives.packages/shared/tsconfig.json (1)
26-30: Configuration cleanup looks correct.The removal of virtual path aliases and
virtual-data-hooks.d.tsfrom the include array aligns with the PR's objective to remove SWR and the virtual data-hooks system. The TypeScript compiler will catch any remaining references to removed modules during build.packages/shared/src/react/hooks/__tests__/wrapper.tsx (1)
3-3: The wrapper change is safe. All context provisioning in tests is handled via module-level mocks (vi.mock('../../contexts', ...)), not by the wrapper component itself. The wrapper serves only as a container forrenderHookand the change fromSWRConfigCompatto a simple fragment does not affect test behavior or functionality.packages/shared/src/react/hooks/useAPIKeys.tsx (1)
105-111: LGTM!The explicit null check for
isSignedInand hardcodedauthenticated: truecorrectly implement the PR objectives to fix hook order issues while maintaining proper authentication gating.packages/shared/src/react/hooks/index.ts (1)
24-24: LGTM!Documentation correctly updated to reflect React Query as the sole implementation.
.changeset/remove-swr-switches.md (1)
1-5: LGTM!Changeset correctly documents the major breaking change.
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.spec.ts (1)
725-725: LGTM!Test correctly updated to remove environment-based branching, now expecting consistent React Query behavior.
packages/shared/src/react/hooks/__tests__/useAPIKeys.spec.tsx (1)
92-92: LGTM!Tests correctly updated to remove environment-based conditionals, expecting consistent React Query revalidation behavior across all scenarios.
packages/shared/src/react/hooks/useStatementQuery.tsx (1)
1-59: LGTM!The hook implementation correctly:
- Guards query execution with
queryEnabledcheck before callingclerk.billing.getStatement- Clears queries on sign-out via
useClearQueriesOnSignOut- Returns a stable result shape matching
StatementQueryResult- Follows the same patterns as other billing hooks in this PR
packages/shared/src/react/contexts.tsx (1)
71-81: LGTM!The
OrganizationProvidersimplification correctly removes the SWR wrapper dependency, aligning with the PR's objective to consolidate on React Query.packages/shared/src/react/hooks/useSubscription.tsx (1)
23-81: LGTM!The implementation correctly:
- Records telemetry on first render only (via
recordedRef)- Clears queries on sign-out
- Normalizes error to
undefinedfor backward compatibility with SWR-based API- Provides
revalidatefunction via query client invalidationpackages/shared/src/react/hooks/__tests__/useSubscription.spec.tsx (1)
94-133: LGTM!The test updates correctly remove environment-flag conditional branches. The unified expectations for sign-out behavior (data becomes
undefinedeven withkeepPreviousData=true) align with the fix for USER-4251, ensuring stale data is properly cleared on sign-out.packages/shared/src/react/hooks/usePlanDetailsQuery.tsx (1)
11-44: LGTM!The implementation correctly:
- Sets
authenticated: falseforuseBillingHookEnabledsince plan details are public data- Uses
initialDataUpdatedAt: 0to treat initial data as immediately stale- Omits
useClearQueriesOnSignOutappropriately since this hook doesn't require authenticationpackages/shared/src/react/hooks/usePagesOrInfinite.tsx (1)
13-112: Core hook structure looks good.The implementation correctly:
- Handles both paginated and infinite query modes
- Uses
useClearQueriesOnSignOutwith proper cleanup callback to reset pagination state- Manages force re-renders for cache-only updates via
forceUpdateCounter
…on bug - Extract pagination calculations into pure utility functions for better testability: - calculateOffsetCount: calculates items to skip based on initial page - calculatePageCount: calculates total pages accounting for offset - calculateHasNextPage: determines if more pages exist - calculateHasPreviousPage: determines if previous pages exist - Fix hasNextPage/hasPreviousPage double multiplication bug where offsetCount was incorrectly multiplied by pageSizeRef.current again - Add comprehensive unit tests for pagination utilities (21 test cases)
|
!snapshot |
|
Hey @jacekradko - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @packages/shared/src/react/hooks/usePagesOrInfinite.tsx:
- Around line 199-205: fetchPrevious can decrement to 0 even though pagination
is 1-based; update the handler in usePagesOrInfinite (fetchPrevious) to clamp to
the configured initialPage (not 0) — e.g. use setPaginatedPage(n =>
Math.max(initialPage, n - 1)) (replace the Math.max(0, ...) call), and include
initialPage in the useCallback dependency array so the clamp honors the
configured default.
🧹 Nitpick comments (1)
packages/shared/src/react/hooks/usePagesOrInfinite.tsx (1)
191-197: Consider using 1 as floor for consistency.Same issue as
fetchPrevious- usingMath.max(0, ...)is inconsistent with the 1-based pagination. While less critical here since incrementing won't reach 0, usingMath.max(1, ...)would be more consistent.Proposed fix
const fetchNext = useCallback(() => { if (triggerInfinite) { void infiniteQuery.fetchNextPage({ cancelRefetch: false }); return; } - setPaginatedPage(n => Math.max(0, n + 1)); + setPaginatedPage(n => Math.max(1, n + 1)); }, [infiniteQuery, triggerInfinite]);
📜 Review details
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.shared.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsx
🧰 Additional context used
📓 Path-based instructions (15)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
All code must pass ESLint checks with the project's configuration
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
packages/**/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Follow established naming conventions (PascalCase for components, camelCase for variables)
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
packages/**/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.ts
**/*.ts?(x)
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use real Clerk instances for integration tests
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Implement type guards forunknowntypes using the patternfunction isType(value: unknown): value is Type
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details in classes
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like<T extends { id: string }>
Use utility types likeOmit,Partial, andPickfor data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Useconst assertionswithas constfor literal types
Usesatisfiesoperator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use ESLint with custom configurations tailored for different package types
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use Prettier for code formatting across all packages
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
**/*
⚙️ CodeRabbit configuration file
If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.
**/*: Only comment on issues that would block merging, ignore minor or stylistic concerns.
Restrict feedback to errors, security risks, or functionality-breaking problems.
Do not post comments on code style, formatting, or non-critical improvements.
Keep reviews short: flag only issues that make the PR unsafe to merge.
Group similar issues into a single comment instead of posting multiple notes.
Skip repetition: if a pattern repeats, mention it once at a summary level only.
Do not add general suggestions, focus strictly on merge-blocking concerns.
If there are no critical problems, respond with minimal approval (e.g., 'Looks good'). Do not add additional review.
Avoid line-by-line commentary unless it highlights a critical bug or security hole.
Highlight only issues that could cause runtime errors, data loss, or severe maintainability issues.
Ignore minor optimization opportunities, focus solely on correctness and safety.
Provide a top-level summary of critical blockers rather than detailed per-line notes.
Comment only when the issue must be resolved before merge, otherwise remain silent.
When in doubt, err on the side of fewer comments, brevity and blocking issues only.
Avoid posting any refactoring issues.
Files:
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.tspackages/shared/src/react/hooks/usePagesOrInfinite.tsxpackages/shared/src/react/hooks/usePagesOrInfinite.shared.ts
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.tsx: Use error boundaries in React components
Minimize re-renders in React components
**/*.tsx: Use proper type definitions for props and state in React components
Leverage TypeScript's type inference where possible in React components
Use proper event types for handlers in React components
Implement proper generic types for reusable React components
Use proper type guards for conditional rendering in React components
Files:
packages/shared/src/react/hooks/usePagesOrInfinite.tsx
**/*.{md,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Update documentation for API changes
Files:
packages/shared/src/react/hooks/usePagesOrInfinite.tsx
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components (e.g.,UserProfile,NavigationMenu)
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Separate UI components from business logic components
Use useState for simple state management in React components
Use useReducer for complex state logic in React components
Implement proper state initialization in React components
Use proper state updates with callbacks in React components
Implement proper state cleanup in React components
Use Context API for theme/authentication state management
Implement proper state persistence in React applications
Use React.memo for expensive components
Implement proper useCallback for handlers in React components
Use proper useMemo for expensive computations in React components
Implement proper virtualization for lists in React components
Use proper code splitting with React.lazy in React applications
Implement proper cleanup in useEffect hooks
Use proper refs for DOM access in React components
Implement proper event listener cleanup in React components
Use proper abort controllers for fetch in React components
Implement proper subscription cleanup in React components
Use proper HTML elements for semantic HTML in React components
Implement proper ARIA attributes for accessibility in React components
Use proper heading hierarchy in React components
Implement proper form labels in React components
Use proper button types in React components
Implement proper focus management for keyboard navigation in React components
Use proper keyboard shortcuts in React components
Implement proper tab order in React components
Use proper ...
Files:
packages/shared/src/react/hooks/usePagesOrInfinite.tsx
🧬 Code graph analysis (1)
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.ts (1)
packages/shared/src/react/hooks/usePagesOrInfinite.shared.ts (4)
calculateOffsetCount(104-106)calculatePageCount(123-125)calculateHasNextPage(144-151)calculateHasPreviousPage(168-170)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (27)
- GitHub Check: Integration Tests (machine, chrome, RQ)
- GitHub Check: Integration Tests (quickstart, chrome, 16)
- GitHub Check: Integration Tests (quickstart, chrome, 15)
- GitHub Check: Integration Tests (nextjs, chrome, 16)
- GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Integration Tests (machine, chrome)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (billing, chrome, RQ)
- GitHub Check: Integration Tests (custom, chrome)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (handshake:staging, chrome)
- GitHub Check: Integration Tests (handshake, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Integration Tests (sessions:staging, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
packages/shared/src/react/hooks/usePagesOrInfinite.shared.ts (1)
88-170: LGTM!The pagination utility functions are well-documented with comprehensive JSDoc comments and examples. The edge case handling (negative page count when offset exceeds total) is appropriately documented in the test file. The logic is correct for standard 1-based pagination.
packages/shared/src/react/hooks/__tests__/usePagesOrInfinite.shared.spec.ts (1)
1-184: LGTM!Comprehensive test coverage for all pagination utilities including edge cases and an integration test demonstrating real-world usage scenarios.
packages/shared/src/react/hooks/usePagesOrInfinite.tsx (1)
1-261: Implementation looks solid overall.The hook correctly integrates React Query for both paginated and infinite modes, properly handles cache management, sign-out cleanup, and derives computed values consistently. The pagination helper functions are used correctly for boundary calculations.
| const fetchPrevious = useCallback(() => { | ||
| if (triggerInfinite) { | ||
| // not natively supported by forward-only pagination; noop | ||
| return; | ||
| } | ||
| setPaginatedPage(n => Math.max(0, n - 1)); | ||
| }, [triggerInfinite]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Page 0 possible with 1-based pagination.
fetchPrevious allows navigating to page 0 when on page 1, but pagination is 1-based (initialPage defaults to 1). While hasPreviousPage guards against this in the UI, direct calls to fetchPrevious could put state into an invalid page 0.
Proposed fix
const fetchPrevious = useCallback(() => {
if (triggerInfinite) {
// not natively supported by forward-only pagination; noop
return;
}
- setPaginatedPage(n => Math.max(0, n - 1));
+ setPaginatedPage(n => Math.max(1, n - 1));
}, [triggerInfinite]);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const fetchPrevious = useCallback(() => { | |
| if (triggerInfinite) { | |
| // not natively supported by forward-only pagination; noop | |
| return; | |
| } | |
| setPaginatedPage(n => Math.max(0, n - 1)); | |
| }, [triggerInfinite]); | |
| const fetchPrevious = useCallback(() => { | |
| if (triggerInfinite) { | |
| // not natively supported by forward-only pagination; noop | |
| return; | |
| } | |
| setPaginatedPage(n => Math.max(1, n - 1)); | |
| }, [triggerInfinite]); |
🤖 Prompt for AI Agents
In @packages/shared/src/react/hooks/usePagesOrInfinite.tsx around lines 199 -
205, fetchPrevious can decrement to 0 even though pagination is 1-based; update
the handler in usePagesOrInfinite (fetchPrevious) to clamp to the configured
initialPage (not 0) — e.g. use setPaginatedPage(n => Math.max(initialPage, n -
1)) (replace the Math.max(0, ...) call), and include initialPage in the
useCallback dependency array so the clamp honors the configured default.
Add useClearQueriesOnSignOut to useInitializePaymentMethod to purge cached externalClientSecret when user signs out. Update queryKey format to match standard cache key pattern and fix placeholderData to respect isEnabled state.
|
!snapshot |
|
Hey @jacekradko - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact |
React Query is now the default, so there's no need for separate RQ matrix entries in unit tests and integration tests.
Description
Removes SWR dependency and fully migrates to TanStack Query (React Query) as the sole data fetching solution. This consolidates our data fetching strategy and eliminates the need for compatibility shims and environment-based switches.
Also includes fixes from #7544 for the
useClearQueriesOnSignOuthook.Fixes: USER-4251
Snapshot deployed to https://github.com/clerk/dashboard/pull/7966
Changes
.swr.tsxand.rq.tsxfile variants, consolidated logic into single filesusePagesOrInfinite.shared.tsTesting Instructions
Manual Testing
Sign-out cache clearing
Pagination hooks
Billing hooks (if applicable)
Acceptance Criteria
Checklist
Type of change