Skip to content

Commit

Permalink
refactor(use-long-press): Remove unnecessary window check in useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
minwork committed Jul 10, 2024
1 parent 394fdde commit 25780ea
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions packages/use-long-press/src/lib/use-long-press.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ export function useLongPress<

// Listen to long press stop events on window
useEffect(() => {
// Do nothing if SSR
if (!window) return;

function listener(event: LongPressDomEvents) {
const reactEvent = createArtificialReactEvent<Target>(event);
cancel()(reactEvent);
Expand Down
2 changes: 1 addition & 1 deletion packages/use-long-press/src/tests/use-long-press.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('Different environment compatibility', () => {
beforeEach(() => {
// Use fake timers for detecting long press
vi.useFakeTimers();
// Simulate absence of TouchEvent
// Simulate absence of window
vi.stubGlobal('window', undefined);
});

Expand Down

0 comments on commit 25780ea

Please sign in to comment.