question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useSwipeable does not refresh callbacks

See original GitHub issue

Describe the bug

It seems that useSwipable does not refresh the handlers on subsequent renders. It appears that the handlers used are the first ones with which the function is called.

Maybe it would need a dependency array, like useImperativeHandle?

(If this behaviour is expected, we should maybe write a description in the README)

Steps or Sandbox to reproduce

https://codesandbox.io/s/p9n13oo0x

Try to swipe two times in the red area, the Page number does not update as expected. In the green area it works, because we are calling the handlers inside a setTimeout() with closured value of the page variable.

Device/Browser

All.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:8

github_iconTop GitHub Comments

3reactions
caesarsolcommented, Apr 17, 2019

Hi @hartzis, thanks for the very quick response and fix!!

Very happy to have been useful. 😃

1reaction
bas-lcommented, Apr 23, 2019

Now running 5.2.0-alpha.4 and everything seems to run well. Thanks @hartzis!

Read more comments on GitHub >

github_iconTop Results From Across the Web

useState with callback not updating useCallback dependencies
If data has already been updated, and useEffect ran the callback, why it is not updated in the dependencies array?
Read more >
react-swipeable - UNPKG
4, * The `first` property of the `SwipeEventData` will be `true` ... 82, * Fix bug where callbacks/props were not refreshed for `useSwipeable`...
Read more >
CHANGELOG.md - FormidableLabs/react-swipeable - Sourcegraph
A swipe lasting more than swipeDuration , in milliseconds, will not be considered ... Fix bug where callbacks/props were not refreshed for useSwipeable...
Read more >
https://raw.githubusercontent.com/dogfessional/rea...
... where toggling this prop did not re-attach event listeners * **update** ... callbacks/props were not refreshed for `useSwipeable` and `<Swipeable>`, ...
Read more >
useAsyncState - VueUse
Export Size. 1.04 kB. Last Changed. yesterday. Reactive async state. Will not block your setup function and will trigger changes once the promise...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found