Skip to content

Commit

Permalink
fix(useMedia): handle query param changes immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
kripod committed Oct 25, 2019
1 parent 0b7de89 commit ccedf58
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/web-api-hooks/src/useMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit ccedf58

Please sign in to comment.