865bd57357
* Allow clicks inside dialog panel when target is inside shadow root * Introduce resettable “server” state This will aid in testing * Add SSR and hydration tests for react * Fix server rendering of Tabs on React 17 * Fix CS * Skip hydration tests * Tweak SSR implementation in Vue * Update changelog
16 lines
463 B
TypeScript
16 lines
463 B
TypeScript
import { watchEffect } from 'vue'
|
|
import { env } from '../utils/env'
|
|
|
|
export function useWindowEvent<TType extends keyof WindowEventMap>(
|
|
type: TType,
|
|
listener: (this: Window, ev: WindowEventMap[TType]) => any,
|
|
options?: boolean | AddEventListenerOptions
|
|
) {
|
|
if (env.isServer) return
|
|
|
|
watchEffect((onInvalidate) => {
|
|
window.addEventListener(type, listener, options)
|
|
onInvalidate(() => window.removeEventListener(type, listener, options))
|
|
})
|
|
}
|