fix(clerk-js): Remove internal useCore hooks#2111
Conversation
🦋 Changeset detectedLatest commit: ee24072 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 |
3a08302 to
37e8513
Compare
37e8513 to
e9d23e0
Compare
dde7159 to
9ad4505
Compare
dimkl
left a comment
There was a problem hiding this comment.
❓ Instead of replacing user. with user?. in the components where useUser() hook is used, shouldn't we add a guard if (!user) return null;?
❓ Instead of adding the if (!user) return null; guard could we move that up the hierarchy to avoid repeating this guard to all the components of eg UserProfile / OrganizationSwitcher? (If so, let's verify that all components that need user have the guard and add a separate PR to make that improvement)
|
|
||
| if (!user) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
❓ is this a fix to avoid rendering PersonalAccountPreview when user is not available or the useCoreUser() has different behaviour from the useUser() ?
There was a problem hiding this comment.
OrganizationList is wrapped in withCoreUserGuard so we are safe. It doesn't really matter if we do user?.something or return null.
Here we did that because it was helping with the deconstruction.
| const { user } = useUser(); | ||
|
|
||
| if (!organization) { | ||
| if (!organization || !user) { |
| const { localizeCustomRole } = useLocalizeCustomRoles(); | ||
| const card = useCardState(); | ||
| const user = useCoreUser(); | ||
| const { user } = useUser(); |
There was a problem hiding this comment.
❓ Don't we need if (!user) return null; guard here?
There was a problem hiding this comment.
OrganizationProfile is wrapped in withCoreUserGuard so we are safe.
b46658d to
41fed9e
Compare
…er -> useSession, useUser
…nization (#2113) this also include useOrganizationList
dc7b7a4 to
ee24072
Compare
Description
This PR:
@clerk/shared/reactasuseSession.@clerk/shared/reactasuseUser.@clerk/shared/reactasuseClerk.The changes for the clerk-js package are applied inside the
ui.rethemeand theuidirectoryChecklist
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