Skip to content
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

onRest is called again after rerender #623

Closed
ThomasDeutsch opened this issue Apr 5, 2019 · 4 comments
Closed

onRest is called again after rerender #623

ThomasDeutsch opened this issue Apr 5, 2019 · 4 comments
Labels
kind: bug Something isn't working
Milestone

Comments

@ThomasDeutsch
Copy link

ThomasDeutsch commented Apr 5, 2019

Problem: Once completed, onRest function is called on every rerender.

minimal codesandbox demo

Expected: the count should only increment once.
Current Behaviour: after rerender the onRest function is called again, and the count gets updated.

Versions in this demo:
"react-spring": "8.0.19",
"react": "16.8.3",
"react-dom": "16.8.3"

@drcmda
Copy link
Member

drcmda commented Apr 5, 2019

It's how onRest is currently working, it animates between 100% and 100% and comes to a rest immediately. If if didn't do that, then you couldn't await async animations, since onRest wouldn't be called once you animate towards a value that's already set.

@ThomasDeutsch
Copy link
Author

ThomasDeutsch commented Apr 5, 2019

understood, thanks for the explanation.

But how can i change the state once, after the animation has finished?
It would be possible if i could get the from-values in onRest like:

onRest(to, from) {
  if(to.width !== from.width) {
   setState(i+1);
  }
} 

@aleclarson
Copy link
Contributor

This will be fixed by #615

@aleclarson aleclarson added the kind: bug Something isn't working label Apr 9, 2019
@aleclarson aleclarson mentioned this issue Apr 10, 2019
5 tasks
@aleclarson
Copy link
Contributor

You can use v9 like this now: yarn add react-spring@next

Let us know how it goes: #642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants