From 26e23693a457976e0d9351e3a2ab1853a03f44b3 Mon Sep 17 00:00:00 2001 From: 2nthony Date: Tue, 28 Sep 2021 14:40:42 +0800 Subject: [PATCH] fix(useMediaQuery): use `tryOnDestroy` (#25) --- packages/core/useMediaQuery/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/useMediaQuery/index.ts b/packages/core/useMediaQuery/index.ts index 5f9a522..dca0e12 100644 --- a/packages/core/useMediaQuery/index.ts +++ b/packages/core/useMediaQuery/index.ts @@ -1,4 +1,4 @@ -import { onDestroy } from 'svelte' +import { tryOnDestroy } from '@svelte-use/shared' import { writable } from 'svelte/store' import { ConfigurableWindow, defaultWindow } from '../_configurable' @@ -26,7 +26,7 @@ export function useMediaQuery(query: string, options: ConfigurableWindow = {}) { mediaQuery.addEventListener('change', handler) - onDestroy(() => { + tryOnDestroy(() => { mediaQuery.removeEventListener('change', handler) })