react-gsap icon indicating copy to clipboard operation
react-gsap copied to clipboard

Comparing children using fast equal check instead of just length

Open bimusiek opened this issue 5 years ago • 4 comments

With previous implementation, when children changed the animation did not work. This PR fixes that.

bimusiek avatar Jan 29 '21 18:01 bimusiek

Theoretically children can be string, null etc. And I am expecting here components with key property so there is obviously room for improvement.

bimusiek avatar Jan 29 '21 18:01 bimusiek

Thanks for the PR. I think we need a real deep check here. There are 2 problems with your solution:

  1. If the children don't have keys (e.g. only one child) it will result in an error and will break current projects
  2. Many people use the array index for the key, so we will have the same problem as before

I hope I'll find some time in the next days, so I'll try to implement a real deep equal check.

bitworking avatar Jan 29 '21 23:01 bitworking

Maybe this could work: https://github.com/FormidableLabs/react-fast-compare

bitworking avatar Jan 29 '21 23:01 bitworking

Ha, I haven’t thought about looking for existing package. Just went with simplest approach for my needs. I will see if I have time over the weekend, then I can submit better PR.

All you comments are obviously valid 👍

bimusiek avatar Jan 29 '21 23:01 bimusiek