Skip to content

Commit bc6cbb0

Browse files
author
alexlee-dev
committed
✏️ Add return types on useMedia
1 parent 04de542 commit bc6cbb0

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

website/src/client/hooks/useMedia.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const useMedia = (
1515
const mediaQueryLists = queries.map((q) => window.matchMedia(q));
1616

1717
// Function that gets value based on matching media query
18-
const getValue = () => {
18+
const getValue = (): any => {
1919
// Get index of first media query that matches
2020
const index = mediaQueryLists.findIndex((mql) => mql.matches);
2121
// Return related value or defaultValue if none
@@ -30,11 +30,11 @@ const useMedia = (
3030
// Event listener callback
3131
// Note: By defining getValue outside of useEffect we ensure that it has ...
3232
// ... current values of hook args (as this hook callback is created once on mount).
33-
const handler = () => setValue(getValue);
33+
const handler = (): void => setValue(getValue);
3434
// Set a listener for each media query with above handler as callback.
3535
mediaQueryLists.forEach((mql) => mql.addListener(handler));
3636
// Remove listeners on cleanup
37-
return () =>
37+
return (): void =>
3838
mediaQueryLists.forEach((mql) => mql.removeListener(handler));
3939
},
4040
[], // Empty array ensures effect is only run on mount and unmount

0 commit comments

Comments
 (0)