chenglou / chenglou/react-motion
this.state.lastIdealStyles[i] fails when children are removed from StaggeredMotion
- Dominant language
- JavaScript
- Stars
- 21.9k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
It might be my particular use case (cant share the code unfortunately), but i can say that the children are propagated via `React.Children.map`.
When child is removed and react-motion attempts to lookup a style value via `this.state.lastIdealStyles[i]`, it fails.
I've fixed this in my fork of react-motion and will gladly put in a pr, but my fix is just a bandaid as other cases could have the children being reordered.
It would seem like a better approach would be to store the previous styles and velocities in a key store by the components key.
##### edit
found https://github.com/chenglou/react-motion/issues/26
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the StaggeredMotion logic where this.state.lastIdealStyles[i] is read, and trace how children from React.Children.map are matched to previous styles and velocities. Reproduce removal and reordering cases, then compare the behavior with the linked issue #26; done means children can be removed or reordered without a style lookup failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100