From ccedf58726b89ce962d80cb2ebbf0c2bbc218e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Fri, 25 Oct 2019 22:39:09 +0200 Subject: [PATCH] fix(useMedia): handle query param changes immediately --- packages/web-api-hooks/src/useMedia.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/web-api-hooks/src/useMedia.ts b/packages/web-api-hooks/src/useMedia.ts index c955f75..ca97ed0 100644 --- a/packages/web-api-hooks/src/useMedia.ts +++ b/packages/web-api-hooks/src/useMedia.ts @@ -26,6 +26,9 @@ export default function useMedia(query: string): boolean { setMatches(mediaQueryList.matches); } + // Handle `query` param changes immediately + handleChange(); + // TODO: Refactor to `managedEventListener` when `change` event is supported mediaQueryList.addListener(handleChange); return () => {