forked from nodejs/nodejs.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add link to documentation, fix styling and use hook for mq, fix docs deep linking * change routing to be all hashed based * only use matchMedia if available * remove set page * removed some console log errors * adding in explicit lint rules, and snaps * revert back to current docs link * snaps
- Loading branch information
1 parent
a03e6ff
commit 215d204
Showing
8 changed files
with
553 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useState, useLayoutEffect } from 'react'; | ||
|
||
export const useMediaQuery = (query: string): boolean | undefined => { | ||
const [matches, setMatches] = useState<boolean>(); | ||
|
||
useLayoutEffect(() => { | ||
if (typeof window.matchMedia === 'function') { | ||
const mq = window.matchMedia(query); | ||
setMatches(mq.matches); | ||
const handler = (): void => setMatches(mq.matches); | ||
mq.addListener(handler); | ||
return (): void => mq.removeListener(handler); | ||
} | ||
}, [query]); | ||
|
||
return matches; | ||
}; |
Oops, something went wrong.