fix(react): Respect ui prop when Clerk instance is passed to IsomorphicClerk#7997
fix(react): Respect ui prop when Clerk instance is passed to IsomorphicClerk#7997
Conversation
🦋 Changeset detectedLatest commit: 1448607 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
!snapshot |
3 similar comments
|
!snapshot |
|
!snapshot |
|
!snapshot |
| @@ -474,7 +474,7 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk { | |||
| this.beforeLoad(clerk); | |||
| // Only load UI scripts in standard browser environments (not native/headless) | |||
| const shouldLoadUi = !this.options.Clerk && this.options.standardBrowser !== false; | |||
There was a problem hiding this comment.
Do you think shouldLoadUi should be false if this.options.ui?.ClerkUI exists? or is that already handled elsewhere?
There was a problem hiding this comment.
Nope. I was mostly starting with a draft PR so I could get snapshots, since this issue wasn't showing up in local testing. The updated change in 2dc46ff should be a better approach, but I still need to test it.
|
!snapshot |
|
!snapshot |
This comment has been minimized.
This comment has been minimized.
|
!snapshot |
This comment has been minimized.
This comment has been minimized.
|
!snapshot |
|
Hey @royanger - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact |
📝 WalkthroughWalkthroughUpdates change IsomorphicClerk UI-loading logic: ClerkUI is now loaded when either (a) 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Throwing this in here for posterity: |
Description
The guard that causes the bug is:
@clerk/react, @clerk/nextjs, etc.: this.options.Clerk is undefined → !this.options.Clerk is true → shouldLoadUi is true → getClerkUIEntryChunk() runs → finds uiProp.ClerkUI from the ui prop and returns it → ClerkUI is valid, no overwrite.
@clerk/chrome-extension: this.options.Clerk is a Clerk instance (truthy) → !this.options.Clerk is false → shouldLoadUi is false → ClerkUI = undefined → overwrites the valid ClerkUI from the ui prop.
The chrome-extension needs its own Clerk instance because it has to wire up extension-specific hooks (JWT handling, cookie syncing, storage cache, etc.) in createClerkClient before the instance is used.
Fix implemented in packages/react/src/isomorphicClerk.ts:
Logic: Load UI when either:
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Bug Fixes
Tests