Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(clerk-react): Properly fire onLoad event when clerk-js is already loaded #2757

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

panteliselef
Copy link
Member

In case of mounting-unmounting-mounting the IsomorphicClerk.addOnLoaded would not fire correctly, hence derivedState would return the initialState instead of the client side state.

In addition to the above fix, we are now cleaning up the IsomorphicClerk instance when the provider is unmounted.

Description

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/backend
  • @clerk/chrome-extension
  • @clerk/clerk-js
  • @clerk/clerk-expo
  • @clerk/fastify
  • gatsby-plugin-clerk
  • @clerk/localizations
  • @clerk/nextjs
  • @clerk/clerk-react
  • @clerk/remix
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/themes
  • @clerk/types
  • build/tooling/chore

… loaded

In case of mounting-unmounting-mounting the `IsomorphicClerk.addOnLoaded` would not fire correctly, hence `derivedState` would return the initialState instead of the client side state.

In addition to the above fix, we are now cleaning up the IsomorphicClerk instance when the provider is unmounted.
Copy link

changeset-bot bot commented Feb 8, 2024

🦋 Changeset detected

Latest commit: 882337d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@clerk/clerk-react Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
gatsby-plugin-clerk Patch
@clerk/nextjs Patch
@clerk/remix Patch

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

return () => {
IsomorphicClerk.clearInstance();
};
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ shouldn't we merge this useEffect with the one above that initializes the isomorphicClerk.addOnLoaded ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual initialization happends in the useMemo
const isomorphicClerk = React.useMemo(() => IsomorphicClerk.getOrCreateInstance(options), []);. So i'm not sure, the position shouldn't affect the result tho.

@panteliselef panteliselef added this pull request to the merge queue Feb 9, 2024
Merged via the queue into main with commit 6ac9e71 Feb 9, 2024
7 checks passed
@panteliselef panteliselef deleted the elef/SDK-1111-fix-unmounted-clerk-provider branch February 9, 2024 09:11
panteliselef added a commit that referenced this pull request Feb 9, 2024
… loaded (#2757)

In case of mounting-unmounting-mounting the `IsomorphicClerk.addOnLoaded` would not fire correctly, hence `derivedState` would return the initialState instead of the client side state.

In addition to the above fix, we are now cleaning up the IsomorphicClerk instance when the provider is unmounted.

(cherry picked from commit 6ac9e71)
github-merge-queue bot pushed a commit that referenced this pull request Feb 9, 2024
… loaded (#2757) (#2767)

In case of mounting-unmounting-mounting the `IsomorphicClerk.addOnLoaded` would not fire correctly, hence `derivedState` would return the initialState instead of the client side state.

In addition to the above fix, we are now cleaning up the IsomorphicClerk instance when the provider is unmounted.

(cherry picked from commit 6ac9e71)

Co-authored-by: panteliselef <panteliselef@outlook.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants