rm two packages for hooks (#251)
* rm two packages for hooks * fix navigation
This commit is contained in:
1 parent
f4c5132d7c
commit
dd9058b798
13 files changed
+188
-272
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import { useSyncExternalStore } from "react"
|
||||
|
||||
export function useMediaQuery(query: string, defaultValue = false): boolean {
|
||||
return useSyncExternalStore(
|
||||
(callback) => {
|
||||
const mql = window.matchMedia(query)
|
||||
mql.addEventListener("change", callback)
|
||||
return () => mql.removeEventListener("change", callback)
|
||||
},
|
||||
() => window.matchMedia(query).matches,
|
||||
() => defaultValue,
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user