Skip to content

Commit

Permalink
feat(shared): Improve useAssertWrappedByClerkProvider messaging (#4719)
Browse files Browse the repository at this point in the history
Co-authored-by: Bryce Kalow <bryce@clerk.dev>
  • Loading branch information
jacekradko and brkalow authored Dec 6, 2024
1 parent 7f3473b commit 4cb2254
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/thick-guests-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/shared': patch
---

Improving error messaging from `useAssertWrappedByClerkProvider` to point out potential failure scenarios.
8 changes: 7 additions & 1 deletion packages/shared/src/react/contexts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ function useAssertWrappedByClerkProvider(displayNameOrFn: string | (() => void))
}

throw new Error(
`${displayNameOrFn} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider`,
`${displayNameOrFn} can only be used within the <ClerkProvider /> component.
Possible fixes:
1. Ensure that the <ClerkProvider /> is correctly wrapping your application where this component is used.
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.
Learn more: https://clerk.com/docs/components/clerk-provider`.trim(),
);
}
}
Expand Down

0 comments on commit 4cb2254

Please sign in to comment.