Skip to content

Commit 7bffc47

Browse files
authoredDec 8, 2023
chore(types,clerk-js,clerk-react): Drop Clerk.isReady() in favor of Clerk.loaded (#2294)
1 parent 1a5f88b commit 7bffc47

File tree

6 files changed

+17
-24
lines changed

6 files changed

+17
-24
lines changed
 

‎.changeset/khaki-buttons-march.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-js': major
3+
'@clerk/clerk-react': major
4+
'@clerk/types': major
5+
---
6+
7+
Drop `Clerk.isReady(). Use `Clerk.loaded` instead.`

‎integration/testUtils/appPageObject.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const createAppPageObject = (testArgs: { page: Page }, app: Application)
3131
},
3232
waitForClerkJsLoaded: async () => {
3333
return page.waitForFunction(() => {
34-
return window.Clerk?.isReady();
34+
return window.Clerk?.loaded;
3535
});
3636
},
3737
waitForClerkComponentMounted: async () => {

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

+7-9
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export class Clerk implements ClerkInterface {
166166
//@ts-expect-error with being undefined even though it's not possible - related to issue with ts and error thrower
167167
#fapiClient: FapiClient;
168168
#instanceType?: InstanceType;
169-
#isReady = false;
169+
#loaded = false;
170170

171171
#listeners: Array<(emission: Resources) => void> = [];
172172
#options: ClerkOptions = {};
@@ -189,7 +189,7 @@ export class Clerk implements ClerkInterface {
189189
}
190190

191191
get loaded(): boolean {
192-
return this.#isReady;
192+
return this.#loaded;
193193
}
194194

195195
get isSatellite(): boolean {
@@ -264,10 +264,8 @@ export class Clerk implements ClerkInterface {
264264

265265
public getFapiClient = (): FapiClient => this.#fapiClient;
266266

267-
public isReady = (): boolean => this.#isReady;
268-
269267
public load = async (options?: ClerkOptions): Promise<void> => {
270-
if (this.#isReady) {
268+
if (this.loaded) {
271269
return;
272270
}
273271

@@ -295,9 +293,9 @@ export class Clerk implements ClerkInterface {
295293
);
296294

297295
if (this.#options.standardBrowser) {
298-
this.#isReady = await this.#loadInStandardBrowser();
296+
this.#loaded = await this.#loadInStandardBrowser();
299297
} else {
300-
this.#isReady = await this.#loadInNonStandardBrowser();
298+
this.#loaded = await this.#loadInNonStandardBrowser();
301299
}
302300
};
303301

@@ -869,7 +867,7 @@ export class Clerk implements ClerkInterface {
869867
params: HandleOAuthCallbackParams = {},
870868
customNavigate?: (to: string) => Promise<unknown>,
871869
): Promise<unknown> => {
872-
if (!this.#isReady || !this.#environment || !this.client) {
870+
if (!this.loaded || !this.#environment || !this.client) {
873871
return;
874872
}
875873
const { signIn, signUp } = this.client;
@@ -1500,7 +1498,7 @@ export class Clerk implements ClerkInterface {
15001498
};
15011499

15021500
#buildUrl = (key: 'signInUrl' | 'signUpUrl', options?: SignInRedirectOptions | SignUpRedirectOptions): string => {
1503-
if (!this.#isReady || !this.#environment || !this.#environment.displayConfig) {
1501+
if (!this.loaded || !this.#environment || !this.#environment.displayConfig) {
15041502
return '';
15051503
}
15061504

‎packages/react/src/isomorphicClerk.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
251251
return false;
252252
}
253253

254-
isReady = (): boolean => Boolean(this.clerkjs?.isReady());
255-
256254
buildSignInUrl = (opts?: RedirectOptions): string | void => {
257255
const callback = () => this.clerkjs?.buildSignInUrl(opts) || '';
258256
if (this.clerkjs && this.#loaded) {
@@ -363,7 +361,7 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
363361
// Otherwise use the instantiated Clerk object
364362
c = this.Clerk;
365363

366-
if (!c.isReady()) {
364+
if (!c.loaded) {
367365
await c.load(this.options);
368366
}
369367
}
@@ -387,7 +385,7 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
387385
await global.Clerk.load(this.options);
388386
}
389387

390-
if (global.Clerk?.loaded || global.Clerk?.isReady()) {
388+
if (global.Clerk?.loaded) {
391389
return this.hydrateClerkJS(global.Clerk);
392390
}
393391
return;

‎packages/types/src/clerk.retheme.ts

-5
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,6 @@ export interface Clerk {
424424
* Handles a 401 response from Frontend API by refreshing the client and session object accordingly
425425
*/
426426
handleUnauthenticated: () => Promise<unknown>;
427-
428-
/**
429-
* Returns true if bootstrapping with Clerk.load has completed successfully. Otherwise, returns false.
430-
*/
431-
isReady: () => boolean;
432427
}
433428

434429
export type HandleOAuthCallbackParams = {

‎packages/types/src/clerk.ts

-5
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,6 @@ export interface Clerk {
424424
* Handles a 401 response from Frontend API by refreshing the client and session object accordingly
425425
*/
426426
handleUnauthenticated: () => Promise<unknown>;
427-
428-
/**
429-
* Returns true if bootstrapping with Clerk.load has completed successfully. Otherwise, returns false.
430-
*/
431-
isReady: () => boolean;
432427
}
433428

434429
export type HandleOAuthCallbackParams = {

0 commit comments

Comments
 (0)
Please sign in to comment.