Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

perf(utils): useMediaQuery #104

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Simon-He95
Copy link
Contributor

No description provided.

@alexzhang1030
Copy link
Sponsor Collaborator

alexzhang1030 commented Jul 4, 2023

There is a bug in the current codebase, isSupported need to be called instead of directly used it:

image

Because isSupported is not a reactive variable, so must re-check every time when running the update function.

Please update, thanks!

@Simon-He95
Copy link
Contributor Author

There is a bug in the current codebase, isSupported need to be called instead of directly used it:

image Because `isSupported` is not a reactive variable, so must re-check every time when running the `update` function.

Please update, thanks!

I know it's a bug, I do it in outer const isSupported = (() => window && 'matchMedia' in window && typeof window.matchMedia === 'function')()

so if we use useMediaQuery multiple, we will never call isSupported

@alexzhang1030
Copy link
Sponsor Collaborator

There is a bug in the current codebase, isSupported need to be called instead of directly used it:
image
Because isSupported is not a reactive variable, so must re-check every time when running the update function.
Please update, thanks!

I know it's a bug, I do it in outer const isSupported = (() => window && 'matchMedia' in window && typeof window.matchMedia === 'function')()

so if we use useMediaQuery multiple, we will never call isSupported

Yeah, I mean Because isSupported is not a reactive variable, so must re-check every time when running the update function.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants