Conversation
🦋 Changeset detectedLatest commit: 06115b2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 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 |
|
dimkl
left a comment
There was a problem hiding this comment.
❓ Instead of adding another Context eg ClerkProviderAssertionContext why not use useIsomorphicClerkContext or useClientContext and apply the same pattern as other hooks?
const ctx = useClientContext();
assertContextExists(ctx, ClientContext);
The assertContextExists already exists in the shared package.
@dimkl So, the interesting thing about that example is that, if That should probably be fixed up, TBD. 👍 Happy to use I'll fix up the existing usage mentioned above with this updated approach. |
a6c9785 to
d4267a5
Compare
dimkl
left a comment
There was a problem hiding this comment.
As part of another PR, I think we also need to consolidate those:
c9302ae to
d4267a5
Compare
d4267a5 to
49e6d01
Compare
…f ClerkProvider [SDK-1043] (#2299) * chore(clerk-js,shared): Add hook to assert the presence of ClerkProvider * chore(clerk-js,clerk-react,shared): Add changeset * chore(shared): Update messaging * chore(clerk-js,shared): Re-used existing context * chore(shared): Require useAssertWrappedByClerkProvider param * Update .changeset/slow-bugs-exist.md * chore(shared): Update error messaging --------- Co-authored-by: Lennart <[email protected]>
Description
Adds and implements
useAssertWrappedByClerkProviderin order to assert thatClerkProvideris present. The goal of this being that we'd like to provide end-users a better development experience.This applies to all public-facing components and hooks.
The intention behind introducing a new context was to limit the amount of refactoring needed to support what we were looking to achieve.
Current error messaging:
AuthContext not foundNew error messaging:
@clerk/clerk-react: useAuth must be used within the <ClerkProvider> component. Please see: https://clerk. com/docs/components/clerk-providerSDK-1043
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change
Packages affected
@clerk/backend@clerk/chrome-extension@clerk/clerk-js@clerk/clerk-expo@clerk/fastifygatsby-plugin-clerk@clerk/localizations@clerk/nextjs@clerk/clerk-react@clerk/remix@clerk/clerk-sdk-node@clerk/shared@clerk/themes@clerk/typesbuild/tooling/chore