Jump to content
Search Community

When using React, should I use...

JasonD test
Moderator Tag

Recommended Posts

In my limited experience working with React and GSAP, I've never needed react-gsap. I don't know much about it or the differences. It looks like it was last updated/published over a year ago so that means it doesn't use GSAP 3. The fact that it's not maintained is another reason not to use it :) 

 

Maybe @OSUblake, @Rodrigo or @elegantseagulls can provide additional insight?

Link to comment
Share on other sites

11 minutes ago, BrownsFanForLife said:

having a tough time with something simple.   I 'JUST WANT TO REVERSE THE MENU'.  https://codesandbox.io/s/great-dream-vt4wb

 

I feel like line 25 should do all the heavy lifting.  What am I missing here?

Your code is equivalent to:

if(showslideMenu) {
  slideMenu.play()
} else {
  slideMenu.reverse();
}

Does that show you why it doesn't work? ;) 

 

You should probably be checking the timeline's .reverse() state instead.

Link to comment
Share on other sites

1 hour ago, OSUblake said:

The joys of using hooks

Indeed, I'd like to know the opinion of those that condemn classes and OOP in JS after seeing that and how simple it is to do it with a class component:

 

https://stackblitz.com/edit/gsap-react-simple-tween?file=simple-tween.js

 

No useEffect, state management or any other weird stuff, just a property and a simple event handler. What's the performance difference? tiny if any...

 

Recommendation: keep using classes when possible (some project managers are fixated on hooks though). I worked on a few projects last year and both used class components and even further plain JS classes instead of Object constructors for some repetitive elements.

 

Don't believe in everything you read regarding classes vs hooks.

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...