Skip to content

useTransition causes rerender loop when array has fewer items #905

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

Closed
BertCh opened this issue Jan 17, 2020 · 3 comments
Closed

useTransition causes rerender loop when array has fewer items #905

BertCh opened this issue Jan 17, 2020 · 3 comments
Labels
kind: bug Something isn't working

Comments

@BertCh
Copy link

BertCh commented Jan 17, 2020

🐛 Bug Report

Each re-render useTransition is passed an array from state. This works fine when adding objects, but when objects are removed from the array it triggers a rerender loop.
possibly related: #636

To Reproduce

Steps to reproduce the behavior:
press the buttons in the sandbox

Expected behavior

The animation seems to get run properly, but the rerender loop is unexpected.

Link to repro (highly encouraged)

bug with useState hook: https://codesandbox.io/s/usetransition-bug-state-v49uq

bug with useReducer hook (slightly more complex): https://codesandbox.io/s/usetransition-bug-25xbr

Environment

  • react-spring v8.x.x or 9.x beta
  • react v16.8
@BertCh BertCh added the kind: bug Something isn't working label Jan 17, 2020
@aleclarson
Copy link
Contributor

Please try with the latest canary.

Note: You'll need to update your useTransition calls. See #809.

@BertCh
Copy link
Author

BertCh commented Jan 17, 2020

woo it works!
Thanks for responding so quickly & for maintaining a good library 👍

@BertCh BertCh closed this as completed Jan 17, 2020
@arackaf
Copy link

arackaf commented Mar 8, 2020

The new useTransition api looks amazing - really looking forward to react-spring 9.

I found this issue after some maddening debugging, trying to figure out why my expired items were not unmounted. Do you think a quick note in your docs warning of this might be useful? EDIT - argghhh I just realized my problem was 100% a consequence of running in concurrent mode. Play on the bleeding edge, get cut :). /EDIT

Also, no pressure of course, but can I ask when you hope to have the current canary released? Very eager to get my hands on it. Thanks for all the hard work - truly appreciated

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

No branches or pull requests

3 participants