fix(clerk-js,shared,clerk-react): Use common cache for swr
Description
Alternative solution to #3091 (but for Core-2) that aims to solve the same issue: How to sync data between hooks and UI components.
A common issue with Clerk so far is that the react hooks that are bundled with a host application will have a different cache than the once used with the bundled UI components from clerk-js.
This PR solves that issue by introducing a single common cache that is created a top level and is passed down to any dependencies.
Scenarios
- clerk-react has its own cache and it is passed down to clerk-js via the
loadmethod (discarding the clerk-js default cache). - clerk-js is used directly and it uses its own cache.
This ensures that when calling useOrganizationList({memberships:true}) from the host app, if the hook has already run and fetched data due to a UI component having been rendered then this will be a cache hit (if data are not stale). Previous that would be a cache miss.
Checklist
- [ ]
npm testruns as expected. - [ ]
npm run buildruns 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:
🦋 Changeset detected
Latest commit: 6d335e84e18ef66768c5c9d38c42ae51b98e6bc1
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 15 packages
| Name | Type |
|---|---|
| @clerk/clerk-js | Minor |
| @clerk/shared | Minor |
| @clerk/clerk-react | Minor |
| @clerk/types | Minor |
| @clerk/chrome-extension | Patch |
| @clerk/clerk-expo | Patch |
| @clerk/backend | Patch |
| @clerk/elements | Patch |
| @clerk/express | Patch |
| @clerk/fastify | Patch |
| @clerk/nextjs | Patch |
| @clerk/remix | Patch |
| @clerk/clerk-sdk-node | Patch |
| @clerk/testing | Patch |
| @clerk/themes | 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
A bug in the implementation was discovered, closing and it is fixed, I will reopen.