Skip to content

Commit 6c64c9b

Browse files
authored
Revert "chore(types,clerk-js,clerk-react): Deprecate Clerk.isReady() in favor of Clerk.loaded (#2293)" (#2441)
This reverts commit a624798.
1 parent 0bf0bdd commit 6c64c9b

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

.changeset/tough-cherries-smoke.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/clerk-react': patch
4+
---
5+
6+
Fix support of Clerk@v3 instance from `<ClerkProvider />`

integration/testUtils/appPageObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const createAppPageObject = (testArgs: { page: Page }, app: Application)
3232
waitForClerkJsLoaded: async () => {
3333
return page.waitForFunction(() => {
3434
// @ts-ignore
35-
return window.Clerk?.loaded;
35+
return window.Clerk?.isReady();
3636
});
3737
},
3838
waitForClerkComponentMounted: async () => {

packages/clerk-js/src/core/clerk.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export default class Clerk implements ClerkInterface {
173173
#environment?: EnvironmentResource | null;
174174
#fapiClient: FapiClient;
175175
#instanceType: InstanceType;
176-
#loaded = false;
176+
#isReady = false;
177177

178178
/**
179179
* @deprecated Although this being a private field, this is a reminder to drop it with the next major release
@@ -200,7 +200,7 @@ export default class Clerk implements ClerkInterface {
200200
}
201201

202202
get loaded(): boolean {
203-
return this.#loaded;
203+
return this.#isReady;
204204
}
205205

206206
get isSatellite(): boolean {
@@ -319,13 +319,10 @@ export default class Clerk implements ClerkInterface {
319319

320320
public getFapiClient = (): FapiClient => this.#fapiClient;
321321

322-
public isReady = (): boolean => {
323-
deprecated('Clerk.isReady()', 'Use `Clerk.loaded` instead.');
324-
return this.#loaded;
325-
};
322+
public isReady = (): boolean => this.#isReady;
326323

327324
public load = async (options?: ClerkOptions): Promise<void> => {
328-
if (this.#loaded) {
325+
if (this.#isReady) {
329326
return;
330327
}
331328

@@ -335,9 +332,9 @@ export default class Clerk implements ClerkInterface {
335332
};
336333

337334
if (this.#options.standardBrowser) {
338-
this.#loaded = await this.#loadInStandardBrowser();
335+
this.#isReady = await this.#loadInStandardBrowser();
339336
} else {
340-
this.#loaded = await this.#loadInNonStandardBrowser();
337+
this.#isReady = await this.#loadInNonStandardBrowser();
341338
}
342339
};
343340

@@ -952,7 +949,7 @@ export default class Clerk implements ClerkInterface {
952949
params: HandleOAuthCallbackParams = {},
953950
customNavigate?: (to: string) => Promise<unknown>,
954951
): Promise<unknown> => {
955-
if (!this.loaded || !this.#environment || !this.client) {
952+
if (!this.#isReady || !this.#environment || !this.client) {
956953
return;
957954
}
958955
const { signIn, signUp } = this.client;
@@ -1622,7 +1619,7 @@ export default class Clerk implements ClerkInterface {
16221619
};
16231620

16241621
#buildUrl = (key: 'signInUrl' | 'signUpUrl', options?: SignInRedirectOptions | SignUpRedirectOptions): string => {
1625-
if (!this.loaded || !this.#environment || !this.#environment.displayConfig) {
1622+
if (!this.#isReady || !this.#environment || !this.#environment.displayConfig) {
16261623
return '';
16271624
}
16281625

packages/react/src/isomorphicClerk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export default class IsomorphicClerk implements IsomorphicLoadedClerk {
363363
// Otherwise use the instantiated Clerk object
364364
c = this.Clerk;
365365

366-
if (!c.loaded) {
366+
if (!c.isReady()) {
367367
await c.load(this.options);
368368
}
369369
}
@@ -390,7 +390,7 @@ export default class IsomorphicClerk implements IsomorphicLoadedClerk {
390390

391391
global.Clerk.sdkMetadata = this.options.sdkMetadata ?? { name: PACKAGE_NAME, version: PACKAGE_VERSION };
392392

393-
if (global.Clerk?.loaded) {
393+
if (global.Clerk?.loaded || global.Clerk?.isReady()) {
394394
return this.hydrateClerkJS(global.Clerk);
395395
}
396396
return;

0 commit comments

Comments
 (0)