FormidableLabs / react-swipeable

React swipe event handler hook
https://commerce.nearform.com/open-source/react-swipeable
MIT License
1.99k stars 146 forks source link

props[onSwipedDir] is not a function #217

Closed ArtemAstakhov closed 3 years ago

ArtemAstakhov commented 3 years ago

Describe the bug Library drops error if hook callback is undefined

Steps or Sandbox to reproduce

const handlers = useSwipeable({
    onSwipedDown: open ? onClose : undefined,
});
cwise89 commented 3 years ago

@ArtemAstakhov Thanks for checking out react-swipable! What you're experiencing is an expected error. Might I suggest this implementation? I confirmed it works ;)

  const handlers = useSwipeable({
    ...(open && { onSwipedDown: onClose })
  });