Skip to content

Commit

Permalink
fix(useMediaQuery): use tryOnDestroy (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
2nthony authored Sep 28, 2021
1 parent 7816cb4 commit 26e2369
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/useMediaQuery/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { onDestroy } from 'svelte'
import { tryOnDestroy } from '@svelte-use/shared'
import { writable } from 'svelte/store'
import { ConfigurableWindow, defaultWindow } from '../_configurable'

Expand Down Expand Up @@ -26,7 +26,7 @@ export function useMediaQuery(query: string, options: ConfigurableWindow = {}) {

mediaQuery.addEventListener('change', handler)

onDestroy(() => {
tryOnDestroy(() => {
mediaQuery.removeEventListener('change', handler)
})

Expand Down

0 comments on commit 26e2369

Please sign in to comment.