mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-29 14:18:26 +02:00
add credenza
This commit is contained in:
parent
a6baebb216
commit
2635443105
9 changed files with 332 additions and 29 deletions
19
src/hooks/useMediaQuery.ts
Normal file
19
src/hooks/useMediaQuery.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import * as React from "react";
|
||||
|
||||
export function useMediaQuery(query: string) {
|
||||
const [value, setValue] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
function onChange(event: MediaQueryListEvent) {
|
||||
setValue(event.matches);
|
||||
}
|
||||
|
||||
const result = matchMedia(query);
|
||||
result.addEventListener("change", onChange);
|
||||
setValue(result.matches);
|
||||
|
||||
return () => result.removeEventListener("change", onChange);
|
||||
}, [query]);
|
||||
|
||||
return value;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue