From a7b810bf068eb79bf631baaadbd63089a9ff6826 Mon Sep 17 00:00:00 2001 From: Sergey Melnikov Date: Wed, 17 Jul 2024 11:05:44 -0400 Subject: [PATCH] Make useMedia options an optional param --- .changeset/shaggy-steaks-look.md | 5 +++++ packages/react-hooks/src/hooks/media.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/shaggy-steaks-look.md diff --git a/.changeset/shaggy-steaks-look.md b/.changeset/shaggy-steaks-look.md new file mode 100644 index 0000000000..cd4f799768 --- /dev/null +++ b/.changeset/shaggy-steaks-look.md @@ -0,0 +1,5 @@ +--- +'@shopify/react-hooks': patch +--- + +Make useMedia options an optional param diff --git a/packages/react-hooks/src/hooks/media.ts b/packages/react-hooks/src/hooks/media.ts index bb4ff276e9..3871615202 100644 --- a/packages/react-hooks/src/hooks/media.ts +++ b/packages/react-hooks/src/hooks/media.ts @@ -3,7 +3,7 @@ import {useState, useEffect, useLayoutEffect} from 'react'; type EffectHook = typeof useEffect | typeof useLayoutEffect; function createUseMediaFactory(useEffectHook: EffectHook) { - return (query: string, {initialValue}: {initialValue?: boolean}) => { + return (query: string, {initialValue}: {initialValue?: boolean} = {}) => { const [match, setMatch] = useState(() => initialValue === undefined ? window.matchMedia(query).matches