Skip to content

Commit

Permalink
[refactor] Remove duplicated useIsomorphicEffect (#5694)
Browse files Browse the repository at this point in the history
* Import useIsomorhicEddext instead of creating new one

* Update create-use-external-events.ts

* fix eslint
  • Loading branch information
qweered committed Feb 9, 2024
1 parent 0731e06 commit 644f6c4
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { useEffect, useLayoutEffect } from 'react';
import { useIsomorphicEffect } from '@mantine/hooks';

function dispatchEvent<T>(type: string, detail?: T) {
window.dispatchEvent(new CustomEvent(type, { detail }));
}

const useIsomorphicEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;

export function createUseExternalEvents<Handlers extends Record<string, (detail: any) => void>>(
prefix: string
) {
Expand Down

0 comments on commit 644f6c4

Please sign in to comment.