Skip to content

Commit

Permalink
fix(clerk-react): Add openCreateOrganization method to isomorphicClerk
Browse files Browse the repository at this point in the history
This was causing `const {openCreateOrganization} = useClerk()` to result in an error when the function was called
  • Loading branch information
panteliselef committed Jun 29, 2023
1 parent 3fee736 commit 968d9c2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-glasses-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-react': patch
---

Populate `openCreateOrganization` return from the `useClerk()` hook
21 changes: 21 additions & 0 deletions packages/react/src/isomorphicClerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default class IsomorphicClerk {
private preopenSignUp?: null | SignUpProps = null;
private preopenUserProfile?: null | UserProfileProps = null;
private preopenOrganizationProfile?: null | OrganizationProfileProps = null;
private preopenCreateOrganization?: null | CreateOrganizationProps = null;
private premountSignInNodes = new Map<HTMLDivElement, SignInProps>();
private premountSignUpNodes = new Map<HTMLDivElement, SignUpProps>();
private premountUserProfileNodes = new Map<HTMLDivElement, UserProfileProps>();
Expand Down Expand Up @@ -239,6 +240,10 @@ export default class IsomorphicClerk {
clerkjs.openUserProfile(this.preopenUserProfile);
}

if (this.preopenCreateOrganization !== null) {
clerkjs.openCreateOrganization(this.preopenCreateOrganization);
}

this.premountSignInNodes.forEach((props: SignInProps, node: HTMLDivElement) => {
clerkjs.mountSignIn(node, props);
});
Expand Down Expand Up @@ -389,6 +394,22 @@ export default class IsomorphicClerk {
}
};

openCreateOrganization = (props?: CreateOrganizationProps): void => {
if (this.clerkjs && this.#loaded) {
this.clerkjs.openCreateOrganization(props);
} else {
this.preopenCreateOrganization = props;
}
};

closeCreateOrganization = (): void => {
if (this.clerkjs && this.#loaded) {
this.clerkjs.closeCreateOrganization();
} else {
this.preopenCreateOrganization = null;
}
};

openSignUp = (props?: SignUpProps): void => {
if (this.clerkjs && this.#loaded) {
this.clerkjs.openSignUp(props);
Expand Down

0 comments on commit 968d9c2

Please sign in to comment.