Skip to content

Commit

Permalink
fix(use-media-query): named export, jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jun 5, 2024
1 parent a25360c commit 2249cfc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/use-media-query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const getServerSnapshotWithoutServerValue = () => {
throw noSSRError('useMediaQuery cannot be used on the server without a serverValue');
};

const useMediaQuery = (mq: string, serverValue?: boolean | undefined): boolean => {
/** @see https://foxact.skk.moe/use-media-query */
export const useMediaQuery = (mq: string, serverValue?: boolean | undefined): boolean => {
if (typeof window !== 'undefined' && !externalStore.has(mq)) {
// This part of the code should only run once per media query, on client-side only
// since we are on the client-side, let's get initial value directly from DOM
Expand All @@ -51,5 +52,3 @@ const useMediaQuery = (mq: string, serverValue?: boolean | undefined): boolean =

return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); // Use useSyncExternalStore to manage the subscription and state
};

export default useMediaQuery;

0 comments on commit 2249cfc

Please sign in to comment.