Skip to content

Commit b3a9ff6

Browse files
committed
chore(clerk-react,shared): Improve assertion error for requiring active organization
1 parent 4e15e06 commit b3a9ff6

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

.changeset/plain-bottles-press.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/shared': patch
3+
'@clerk/clerk-react': patch
4+
---
5+
6+
Improve assertion error for requiring active organization.

packages/react/src/components/CheckoutButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ export const CheckoutButton = withClerk(
6363
}
6464

6565
if (orgId === null && _for === 'organization') {
66-
throw new Error('Wrap `<CheckoutButton for="organization" />` with a check for an active organization.');
66+
throw new Error(
67+
'Wrap `<CheckoutButton for="organization" />` with a check for an active organization. Retrieve `orgId` from `useAuth()` and confirm it is defined. For SSR, see: https://clerk.com/docs/references/backend/types/auth-object#how-to-access-the-auth-object',
68+
);
6769
}
6870

6971
children = normalizeWithDefaultValue(children, 'Checkout');

packages/react/src/components/SubscriptionDetailsButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const SubscriptionDetailsButton = withClerk(
5858

5959
if (orgId === null && _for === 'organization') {
6060
throw new Error(
61-
'Wrap `<SubscriptionDetailsButton for="organization" />` with a check for an active organization.',
61+
'Wrap `<SubscriptionDetailsButton for="organization" />` with a check for an active organization. Retrieve `orgId` from `useAuth()` and confirm it is defined. For SSR, see: https://clerk.com/docs/references/backend/types/auth-object#how-to-access-the-auth-object',
6262
);
6363
}
6464

packages/shared/src/react/hooks/useCheckout.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ export const useCheckout = (options?: Params): __experimental_UseCheckoutReturn
8484
}
8585

8686
if (forOrganization === 'organization' && !organization) {
87-
throw new Error('Clerk: Wrap your flow with a check for an active organization');
87+
throw new Error(
88+
'Clerk: Ensure your flow checks for an active organization. Retrieve `orgId` from `useAuth()` and confirm it is defined. For SSR, see: https://clerk.com/docs/references/backend/types/auth-object#how-to-access-the-auth-object',
89+
);
8890
}
8991

9092
const manager = useMemo(

0 commit comments

Comments
 (0)