Update formatting

This commit is contained in:
Isabelle Viktoria Maciohsek
2022-01-30 19:41:09 +02:00
parent 790f0de37f
commit e7988c0065
6 changed files with 7 additions and 7 deletions

View File

@ -7,8 +7,8 @@ lastUpdated: 2021-10-13T19:29:39+02:00
Checks if the current environment matches a given media query and returns the appropriate value.
- Check if `window` and `window.matchMedia` exist. Return `whenFalse` if not (e.g. SSR environment or unsupported browser).
- Use `window.matchMedia()` to match the given `query`. Cast its `matches` property to a boolean and store in a state variable, `match`, using the `useState()` hook.
- Check if `Window` and `Window.matchMedia()` exist. Return `whenFalse` if not (e.g. SSR environment or unsupported browser).
- Use `Window.matchMedia()` to match the given `query`. Cast its `matches` property to a boolean and store in a state variable, `match`, using the `useState()` hook.
- Use the `useEffect()` hook to add a listener for changes and to clean up the listeners after the hook is destroyed.
- Return either `whenTrue` or `whenFalse` based on the value of `match`.