-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useSwipeable does not refresh callbacks #136
Comments
I have the same issue. Upon swiping I do a callback that updates a prop in the parent, and the prop is updated in the render function, but not in the handler. Is it possible this would also be fixed by #135? |
@caesarsol Thank you for the issue and the example, incredibly helpful being able to reproduce. Great question about if this is expected or not. I'm intrigued by the @bas-l I do think it is related to #135 too, but that is for the component, I'm going to dig a bit more into this. And please let me know if you think you have a solution or thoughts on if this should or shouldn't be expected. |
@caesarsol @bas-l @stephencookdev It is late, but i may have solved it? It may not be elegant but i think it works. #138 published as @caesarsol I forked your codesandbox, again THANK YOU, and with |
@hartzis Thanks for the quick update! Only now Typescript cannot find the
Oh I only now see #137. Waiting for that now I guess :-) Going back to 5.1.0 for now. |
@bas-l I just merged #137 , funny i just made that last night too. I just cut another alpha, |
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! |
fix published with |
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, likeuseImperativeHandle
?(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 thepage
variable.Device/Browser
All.
The text was updated successfully, but these errors were encountered: