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

[refer-global-this] if (typeof window === 'undefined') #2492

Closed
tjx666 opened this issue Nov 2, 2024 · 1 comment
Closed

[refer-global-this] if (typeof window === 'undefined') #2492

tjx666 opened this issue Nov 2, 2024 · 1 comment
Labels

Comments

@tjx666
Copy link

tjx666 commented Nov 2, 2024

check typeof globalThis === 'undefied' is different with typeof window === 'undefined'

unicorn/prefer-global-this

let clientQueryClientSingleton: QueryClient;
function getQueryClient() {
    if (typeof window === 'undefined') {
        // Server: always make a new query client
        return makeQueryClient();
    }
    // Browser: use singleton pattern to keep the same query client
    return (clientQueryClientSingleton ??= makeQueryClient());
}```
@tjx666 tjx666 added the bug label Nov 2, 2024
@fregante fregante closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2024
@fregante
Copy link
Collaborator

fregante commented Nov 4, 2024

Duplicate of #2468

@fregante fregante marked this as a duplicate of #2468 Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants