UNPKG

1.5 kBPlain TextView Raw
1export const noFrontendApiError =
2 'Clerk: You must add the frontendApi prop to your <ClerkProvider>';
3
4export const noClerkProviderError =
5 'Clerk: You must wrap your application in a <ClerkProvider> component.';
6
7export const noGuaranteedLoadedError = (hookName: string) =>
8 `Clerk: You're calling ${hookName} before there's a guarantee the client has been loaded. Call ${hookName} from a child of <SignedIn>, <SignedOut>, or <ClerkLoaded>, or use the withClerk() HOC.`;
9
10export const noGuaranteedUserError = (hookName: string) =>
11 `Clerk: You're calling ${hookName} before there's a guarantee there's an active user. Call ${hookName} from a child of <SignedIn> or use the withUser() HOC.`;
12
13export const multipleClerkProvidersError =
14 "Clerk: You've added multiple <ClerkProvider> components in your React component tree. Wrap your components in a single <ClerkProvider>.";
15
16export const hocChildrenNotAFunctionError =
17 'Clerk: Child of WithClerk must be a function.';
18
19export const multipleChildrenInButtonComponent = (name: string) =>
20 `Clerk: You've passed multiple children components to <${name}/>. You can only pass a single child component or text.`;
21
22export const MagicLinkErrorCode = {
23 Expired: 'expired',
24 Failed: 'failed',
25};
26
27type MagicLinkError = {
28 code: 'expired' | 'failed';
29};
30
31export function isMagicLinkError(err: any): err is MagicLinkError {
32 return (
33 !!err &&
34 (err.code === MagicLinkErrorCode.Expired ||
35 err.code === MagicLinkErrorCode.Failed)
36 );
37}