Skip to content

Commit 4cb2254

Browse files
jacekradkobrkalow
andauthored
feat(shared): Improve useAssertWrappedByClerkProvider messaging (#4719)
Co-authored-by: Bryce Kalow <bryce@clerk.dev>
1 parent 7f3473b commit 4cb2254

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/thick-guests-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/shared': patch
3+
---
4+
5+
Improving error messaging from `useAssertWrappedByClerkProvider` to point out potential failure scenarios.

packages/shared/src/react/contexts.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ function useAssertWrappedByClerkProvider(displayNameOrFn: string | (() => void))
7171
}
7272

7373
throw new Error(
74-
`${displayNameOrFn} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider`,
74+
`${displayNameOrFn} can only be used within the <ClerkProvider /> component.
75+
76+
Possible fixes:
77+
1. Ensure that the <ClerkProvider /> is correctly wrapping your application where this component is used.
78+
2. Check for multiple versions of the \`@clerk/shared\` package in your project. Use a tool like \`npm ls @clerk/shared\` to identify multiple versions, and update your dependencies to only rely on one.
79+
80+
Learn more: https://clerk.com/docs/components/clerk-provider`.trim(),
7581
);
7682
}
7783
}

0 commit comments

Comments
 (0)