-
Notifications
You must be signed in to change notification settings - Fork 337
fix(shared): Force disable swr devtools for organization hooks #1694
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
Conversation
🦋 Changeset detectedLatest commit: a71f6bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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 |
!snapshot |
Hey @panteliselef - the snapshot version command generated the following package versions:
Tip: use the snippet copy button below to quickly install the required packages. # @clerk/chrome-extension
npm i @clerk/[email protected] # @clerk/clerk-js
npm i @clerk/[email protected] # @clerk/clerk-expo
npm i @clerk/[email protected] # gatsby-plugin-clerk
npm i [email protected] # @clerk/nextjs
npm i @clerk/[email protected] # @clerk/clerk-react
npm i @clerk/[email protected] # @clerk/remix
npm i @clerk/[email protected] # @clerk/shared
npm i @clerk/[email protected] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job tracking this one down @panteliselef :)
|
||
import { disableSWRDevtools } from './clerk-swr'; | ||
disableSWRDevtools(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is a top-level side effect already, I think we can simply call it inside once inside clerk-swr.ts
directly.
If we wanted to avoid top-level side-effects altogether, an alternative approach would be to create our own SWR wrapper and call disableSWRDevtools
internally, eg:
import { useSWR as _useSWR } from 'swr';
export useSWR = () => {
disableSWRDevtools();
return _useSWR;
}
No real preference here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We tried this, but was not working.
// file: clerk-swr.ts
if (typeof window !== 'undefined') {
// @ts-ignore
window.__SWR_DEVTOOLS_USE__ = undefined;
}
export * from 'swr';
export { default as useSWR } from 'swr';
export { default as useSWRInfinite } from 'swr/infinite';
Also swr setups the devtools once imported not once the hooks is called. Do you think your recommendation would still work with that in mind ?
b000370
to
8787c05
Compare
8787c05
to
a71f6bb
Compare
This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Type of change
Packages affected
@clerk/clerk-js
@clerk/clerk-react
@clerk/nextjs
@clerk/remix
@clerk/types
@clerk/themes
@clerk/localizations
@clerk/clerk-expo
@clerk/backend
@clerk/clerk-sdk-node
@clerk/shared
@clerk/fastify
@clerk/chrome-extension
gatsby-plugin-clerk
build/tooling/chore
Description
npm test
runs as expected.npm run build
runs as expected.This PR fixes a bug where the application would break if the SWR Devtools extention was enabled in the broswer.
See 👉 SWR Devtool Issue
By overriding the window.SWR_DEVTOOLS_USE with a false value before importing swr, enables us to disable swr from "hinting" to swr-devtools which react version to use.
Clerk Dashboard
Before
Screen.Recording.2023-09-07.at.8.40.55.PM.mov
After
Screen.Recording.2023-09-07.at.8.41.26.PM.mov