bitworking / react-gsap

React components for GSAP
https://bitworking.github.io/react-gsap/
Other
583 stars 34 forks source link

Comparing children using fast equal check instead of just length #34

Open bimusiek opened 3 years ago

bimusiek commented 3 years ago

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

bimusiek commented 3 years ago

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

bitworking commented 3 years ago

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 commented 3 years ago

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

bimusiek commented 3 years ago

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 👍