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.

Array items rearrange with useTransition

See original GitHub issue

🐛 Bug Report

When using useTransition with an array of items, when the items are transitioning out of the DOM, the order of the items changes; the array is rearranged.

GIPHY

https://codesandbox.io/s/react-spring-cards-reordering-8tckt

To Reproduce

Steps to reproduce the behavior: See sandbox: https://codesandbox.io/s/react-spring-cards-reordering-8tckt

When using useTransition from [ 1, 2 ] to [ 1, 2, 3, 4] back to [ 1, 2 ], the order temporarily changes to [ 4, 1, 2, 3 ] while the transition is happening.

Expected behavior

I would expect the order to stay the same while transitioning back (it should always be [ 1, 2, 3, 4 ])

Link to repro (highly encouraged)

https://codesandbox.io/s/react-spring-cards-reordering-8tckt

Environment

  • react-spring v8.0.27
  • react v16.12.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
ruthmpardeecommented, Jun 10, 2020

Confirmed this bug is not happening in v9: https://codesandbox.io/s/react-spring-cards-reordering-v9-dpfm1

0reactions
joshuaelliscommented, Mar 18, 2021

closing due to inactivity & it’s fixed in v9. please use discussions or discord if you want more help or please consider creating a PR if you want to add a feature 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

useTransition on Array return undefined Array propeties ...
The API for useTransition has change in v9 and is documented. ... return ( <> <div className="ppl-lst"> {transitions((props, item) ...
Read more >
useTransition "update" prop applies when order is unchanged
We could add a reorder prop, which updates the animations of any item with a new ... @aleclarson i thought update prop triggers...
Read more >
useTransition - React Docs
useTransition returns an array with exactly two items: ... For example, if the user clicks a tab but then change their mind and...
Read more >
useTransition and useDeferredValue in React 18
Since there are 20,000 elements in the array, filtering is going to be ... useTransition hook to tell React that a certain state...
Read more >
useTransition - react-spring
Item is defined a lot below, it's automatically inferred from what you pass as the content of the array you pass as the...
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