useSwipeable does not refresh callbacks
See original GitHub issueDescribe 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:
- Created 4 years ago
- Reactions:4
- Comments:8
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @hartzis, thanks for the very quick response and fix!!
Very happy to have been useful. 😃
Now running 5.2.0-alpha.4 and everything seems to run well. Thanks @hartzis!