EASY React Animation with useGSAP()

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • GSAP itself is completely framework-agnostic and can be used in any JS framework without any special wrappers or dependencies. However, this hook solves a few React-specific friction points for you so that you can just focus on the fun stuff. 🤘🏻
    useGSAP() is a drop-in replacement for useEffect() or useLayoutEffect() that automatically handles cleanup using gsap.context().
    Import the useGSAP() hook from @gsap/react and you're good to go! All GSAP animations, ScrollTriggers, Draggables, and SplitText instances created when the useGSAP() hook executes will be reverted automatically when the component unmounts and the hook is torn down.
    To learn more, head over to gsap.com/react
    @gsap/react on npm → www.npmjs.com/package/@gsap/r...
    codepen starter → codepen.io/GreenSock/pen/OJmQvLZ
    StackBlitz starter → stackblitz.com/edit/gsap-reac...
    ----- Video Contents -----
    00:00 - Intro
    01:02 - What is useGSAP?
    01:22 - Why is it useful in React?
    02:21 - Cleanup with gsap.context (the old way)
    03:19 - useGSAP() (the new way)
    04:13 - Scope for selector text
    06:04 - Dependencies (reacting to changes in state)
    08:10 - contextSafe (animating on interaction)
    12:09 - Bye!
  • Věda a technologie

Komentáře • 169

  • @shadowslayer2248
    @shadowslayer2248 Před 2 měsíci +12

    Her smile is as beautiful as the easy integration of GSAP with React and smoothness by which GSAP controls and animates the DOM elements. Thank you instructor and mainly thank you developers for the useGSAP hook which makes it so easy, gimme a second to acknowledge your greatness 🙇‍♂🙇‍♂🙏🙏

  • @paakofibamfoquaicoe4193
    @paakofibamfoquaicoe4193 Před 4 měsíci +10

    Your laughing and smiling throughout the video makes me happy. Great video. Thank you.

  • @arkondigital1496
    @arkondigital1496 Před 14 dny +1

    This is the best tutorial I've watched recently in terms of clean delivery and the chill and happy energy you both give out!

  • @chrisandrew_tv
    @chrisandrew_tv Před 4 měsíci +6

    That's the affectionate and mildly manic smile all develop who have dared attempt complex GSAP animations in React 18 (because it's better to smile than to cry) 😂

  • @shash0_0
    @shash0_0 Před 4 měsíci +4

    Clear, succinct and comprehensive. Your calm energy is just cherry on top!

  • @kapeeshmanilal1613
    @kapeeshmanilal1613 Před 6 měsíci +8

    Oh I've been waiting for this! Good work team! 💚

  • @sirajahmed8034
    @sirajahmed8034 Před měsícem +1

    Wow!
    It always pained me how hard it was to use gsap with React, and I'm glad a proper hook was created that addresses all the issues. Very excited to use this, amazing work by GSAP team!

  • @user-gf6jw7bm8b
    @user-gf6jw7bm8b Před 5 měsíci +1

    Amazing work here, seeing the react hook type syntax with GSAP in it on the thumbnail blew my mind. As always, excellent tutorial by Cassie and great documentation. Will definitely be using it soon enough !

  • @fortysyv
    @fortysyv Před 5 měsíci

    This is so awesome. I started my animation journey with gsap but had to switch when I started working in react. I'm so glad you found a solution for the too many refs problem. Thank you. Definitely gonna try this out in my next project

  • @metalyx1
    @metalyx1 Před 5 měsíci +4

    Had these issues with cleaning up and killing animations, it's perfect you have a hook. Works amazing, just plug and play 👏

  • @mr-skorpion
    @mr-skorpion Před 4 měsíci +5

    Beautiful addition to Gsap React ecosystem, thank you team GSAP 👍✨

  • @shableep
    @shableep Před 5 měsíci +11

    whoa this got released just in time for me to build my portfolio site. thank you! you're covering so many important essentials and esoteric React concepts.

  • @Michael-Martell
    @Michael-Martell Před 5 měsíci +4

    Props to all your hard work, not only on this video, but on the documentation and the Starter examples on Stack blitz. It’s extremely helpful! I’ll be playing with it this week and I think I’ll be finally taking the leap into Paid GSAP after my next check! Thanks for all you do!

    • @GreenSockLearning
      @GreenSockLearning  Před 5 měsíci +1

      Oh this is so nice to hear, thanks for taking the time to leave such a nice message - pop into the forums if you have any feedback or need any help. 💚

  • @montoyland
    @montoyland Před 6 měsíci +4

    I love how you incorporated Brody into your presentation! It's a testament to your natural ability to go with the flow that, while appears so effortless, takes great skill. Your instructions were clear and speak to larger concerns all React developers should consider even beyond specifically using GSAP. Thanks for the obvious effort you took to show us best practices!

    • @cassieevans604
      @cassieevans604 Před 6 měsíci

      I just had to accept that Brody just pops by occasionally, even if I'm recording, I have no choice in the matter. If I try to lock him out of my office he howls until I let him in 😂

  • @xdmemeguy
    @xdmemeguy Před 5 měsíci +2

    I love how calmly you explain things.

  • @44turtlepower
    @44turtlepower Před 6 měsíci +1

    Amazing developments! Nice work, and thank you!

  • @joshreynolds4164
    @joshreynolds4164 Před 6 měsíci

    Wow what an excellent demo of this. Thanks!

  • @Dan21789
    @Dan21789 Před 6 měsíci

    Incredible! What a great explainer video. I’m excited to try this out!

  • @user-kf1gz7xg1c
    @user-kf1gz7xg1c Před 6 měsíci

    I must learn gsap after this video, and ofc try this hook. Nice job 👏

  • @marianop8882
    @marianop8882 Před 6 měsíci +1

    This us pure gold! Thank you, Cassie

  • @radezzientertainment501
    @radezzientertainment501 Před 3 měsíci

    this was a tremendous walkthrough, thank u!!

  • @snorklTV
    @snorklTV Před 6 měsíci +13

    wow. fantastic job on the video! editing is crazy good. can't even imagine how long it took to put it all together and have it flow so well.

    • @cassieevans604
      @cassieevans604 Před 6 měsíci

      Means a lot Carl, thanks. I STILL messed up with an audio overlap at 7:40. I'm getting better though, it's a whole skill in itself, I have so much more respect for video creators now. Time consuming stuff. 😂

    • @digitalsahara6670
      @digitalsahara6670 Před 6 měsíci +1

      will you be working on some react content in the future?

    • @luisvisintini833
      @luisvisintini833 Před 5 měsíci

      will you be working on some react content in the future?

    • @snorklTV
      @snorklTV Před 5 měsíci +3

      Thanks for your interest in my GSAP training. No immediate plans for React at this time. The GSAP team has really great resources to get you going.

    • @luisvisintini833
      @luisvisintini833 Před 5 měsíci

      @@snorklTV Thank you for the answer! I have your course! And it's extremely great! Do you know any gsap course with react?

  • @justinoconnell7307
    @justinoconnell7307 Před 6 měsíci

    This was a great video, I’ll be testing it out

  • @tirthgajjar797
    @tirthgajjar797 Před 6 měsíci

    Very imortant update, great video.

  • @shehzadasif7177
    @shehzadasif7177 Před 6 měsíci

    It might be a problem solving hook for cleanup issues. Great work

  • @jior6
    @jior6 Před 6 měsíci +29

    It should be illegal to use your guys' platform for free. I'm absolutely blown away how vastly superior GSAP compares to other animation solutions. Very well done.

    • @GreenSockLearning
      @GreenSockLearning  Před 5 měsíci +7

      Ha, This made us laugh, thanks 💚Honestly though - We appreciate every person that supports our development work through Club GSAP! That support allows us to keep the tools free for the majority.

    • @itgiants5218
      @itgiants5218 Před 5 měsíci +2

      @@GreenSockLearning we do really appreciate your amazing continuous efforts, great job.

    • @EmmanuelNgwandu
      @EmmanuelNgwandu Před 5 měsíci +1

      Officially starting using gsap in my react projects. Awesome

  • @mikoajszczepkowski4513
    @mikoajszczepkowski4513 Před 6 měsíci

    Finally! GSAP rocks

  • @kevinat71
    @kevinat71 Před 5 měsíci

    More tutorial with useGSAP please! .... Thanks a lot for this, fantastic job ❤

  • @nikhilpsathyanathan
    @nikhilpsathyanathan Před 6 měsíci

    it simplify a lot and nice presentation

  • @ziadx3
    @ziadx3 Před 6 měsíci

    Great work!

  • @BooksWeCanRead
    @BooksWeCanRead Před 6 měsíci

    Oooh niiice!! ❤❤ praise be!! 🙌🙌

  • @aaravgavshinde1296
    @aaravgavshinde1296 Před 2 měsíci

    Took a little too much brain cells to understand, but got it watching twice! Nice video, thanks a lot!

  • @sjorsroelofs
    @sjorsroelofs Před 6 měsíci +1

    Awesome hook! Your presentations are always very good👍🏻

  • @gorki90
    @gorki90 Před 6 měsíci +8

    Great and easily understandable presentation. Also, the video editing is top notch! I'm impressed!

    • @gorki90
      @gorki90 Před 6 měsíci

      Except a little bug at 7:41 :P

    • @cassieevans604
      @cassieevans604 Před 6 měsíci

      argh. There's always one 🫠 @@gorki90

  • @otfnk
    @otfnk Před 6 měsíci +2

    Awesome tutorial. I will be improving readability and clean code with this hook. I am feeling lucky to see this video. 🎉❤

  • @kkr9925
    @kkr9925 Před 4 měsíci

    Great presentation.

  • @snatvb
    @snatvb Před 6 měsíci

    wow, nice work)

  • @joshuayullu
    @joshuayullu Před 4 měsíci +1

    had me at "awkwardly named bit of nonsense"😂

  • @criticalcritics6531
    @criticalcritics6531 Před 5 měsíci

    You're so good!

  • @saeedakhshijan8159
    @saeedakhshijan8159 Před 6 měsíci

    GSAP is lovely ❤

  • @irfansaeedkhan7242
    @irfansaeedkhan7242 Před 6 měsíci

    wow very much needed

  • @franklinaldo4566
    @franklinaldo4566 Před 6 měsíci

    Love it!

  • @Seacrest.
    @Seacrest. Před 6 měsíci

    nice! thanks!

  • @shervangh9660
    @shervangh9660 Před 5 měsíci

    tnx for your content

  • @user-ok9zi7tr2l
    @user-ok9zi7tr2l Před 6 měsíci

    it's amazing

  • @jeresalem
    @jeresalem Před 5 měsíci

    Absolutely awesome. Thank you for making this!

  • @hayesmaker64
    @hayesmaker64 Před 2 měsíci

    "drowining in a sea of refs.." - yep, I know that feeling!

  • @TaimoorShahzada
    @TaimoorShahzada Před 6 měsíci

    🙏 Thanks for that

  • @miGuHD
    @miGuHD Před 6 měsíci

    A little audio overlap happening around 7:40 but pretty stocked about the React love you're sending us lately, thanks!

    • @GreenSockLearning
      @GreenSockLearning  Před 6 měsíci +1

      It's a shame youtube doesn't allow re-uploads, but thanks for the spot.

  • @gerguno
    @gerguno Před 5 měsíci

    Nice and smart girl!

  • @niharmondol1415
    @niharmondol1415 Před 5 měsíci

    It’s a great video mam ❤
    Provide some use cases scroll trigger animation using react and gsap.
    Again thank you 🙏

  • @cafelutsa_
    @cafelutsa_ Před 6 měsíci

    awesome

  • @asifiweebenezer3166
    @asifiweebenezer3166 Před 6 měsíci

    I am going to Use GSAP in my Gatsby project. It's the first time I'm using GSAP and Gatsby. I really need this. Thanks

  • @zubayerhossain7074
    @zubayerhossain7074 Před 5 měsíci

    Nice work! appreciate your kindness for publishing it free!

  • @ayushgogna9732
    @ayushgogna9732 Před 6 měsíci

    finally waited for this for so long

  • @kenshinhimura3140
    @kenshinhimura3140 Před 6 měsíci

    Thank you my poussy

  • @A...A..A
    @A...A..A Před 6 měsíci +1

    Can we use it for react native expo or any advice except animated for expo?

  • @stylrart
    @stylrart Před měsícem

    smart dev

  • @Trazynn
    @Trazynn Před 6 měsíci +4

    (I bet this comment will hit the spam filter because I mention Discord but i'll try it anway). In the Framer discord there's frequent questions on how to implement GSAP animations into Framer websites. Some short video showcasing how to do that would be quite valuable.

    • @GreenSockLearning
      @GreenSockLearning  Před 6 měsíci

      Thanks for the feedback - We're not really familiar with framer's GUI, but GSAP is just JS and can be added wherever you can add custom code.

  • @chrishare3273
    @chrishare3273 Před 6 měsíci

    yay!

  • @mentasuavesuave01
    @mentasuavesuave01 Před 6 měsíci

    I'm here since I know you from a podcast and I want to know where I can practice GSAP if I want to become better, is there a page with exercises somewhere? I'm the one who learn by doing

  • @rasangalakshith1131
    @rasangalakshith1131 Před 19 dny

    can I use this useGSAP hook in nextjs static site generation rendering?

  • @SwOOp_de
    @SwOOp_de Před 5 měsíci

    😍Cassie

  • @lasindunuwanga5292
    @lasindunuwanga5292 Před 5 měsíci

    Me: I like that accent. I wonder where it comes from
    Also me: React is now a framework
    Some random guy: Don't take everything literally

  • @natnaelt1744
    @natnaelt1744 Před 5 měsíci

    Nice will add this to my bag, what breed of dog is that btw😅 so cute

    • @GreenSockLearning
      @GreenSockLearning  Před 5 měsíci

      He's a rescue street dog so we don't know what sort. He's a good boy though. 🐕

  • @xelinel32
    @xelinel32 Před 6 měsíci

    for vue.js do u planning something like this?

  • @michaelmiranda3220
    @michaelmiranda3220 Před 2 měsíci

    Hi, How do I properly use matchMedia inside the hook?

  • @Michael-Martell
    @Michael-Martell Před 4 měsíci

    Btw, your stackblitz example for your Next13 Page transitions is not currently working… it’s failing at the start command.

  • @absartb7789
    @absartb7789 Před 6 měsíci +1

    Thanks for the hook!, but what if i need to use matchMedia that already has context within it?

    • @GreenSockLearning
      @GreenSockLearning  Před 6 měsíci +1

      Hey there! Good question, you can use matchMedia inside useGSAP, useGSAP will revert the matchMedia context. codepen.io/GreenSock/pen/OJmQvLZ
      We'll add this to the docs!

  • @user-rz1fg4fe1e
    @user-rz1fg4fe1e Před 6 měsíci +1

    чудесная девушка, еще и умная)

  • @tom7050
    @tom7050 Před 5 měsíci

    O M G

  • @mazwrld
    @mazwrld Před 6 měsíci

    ❤❤❤❤

  • @madebyjonny7637
    @madebyjonny7637 Před 5 měsíci

    like for the dog, great video though 😅

  • @mendaxassange4465
    @mendaxassange4465 Před 4 měsíci

    can anyone point out to me how I can animate during unmount and mount using gsap. like modal view and exit.

  • @marcusdillgen
    @marcusdillgen Před 6 měsíci

    Nice, that came at the right time!!! I also have to praise Cassie's videos. They are always some of the best learning material you can find.

    • @cassieevans604
      @cassieevans604 Před 6 měsíci

      I love to hear this 💚 Always trying to get better at it!

  • @giorgosphilippou81
    @giorgosphilippou81 Před 5 měsíci

    Is this working for React Native too?

  • @ashifuddin_ahmed17
    @ashifuddin_ahmed17 Před 2 měsíci +1

    0:07
    React is a Library, not a framework...☺

  • @karansagar7870
    @karansagar7870 Před 5 měsíci

    looks worth giving a try , also will be spamming here if things break.

  • @ndukachukz8067
    @ndukachukz8067 Před 6 měsíci

    What is she smiling at❤😂🌹

  • @sarahlauren4834
    @sarahlauren4834 Před 6 měsíci

    Wooow ! Is that the Pixel Spirit Deck in the background ? ( Maybe I should use it after all this time ) ;) Otherwise, great video, I'm going to check out this new hook ! Thanks. ☀

  • @angry_moose94
    @angry_moose94 Před 6 měsíci

    Hey nice library but it just seems like it’s a lot of work for animations that you can probably do with css. I mean even librairies like framer motion are probably gonna turn obsolete when the browsers can do it by themselves. Animations are nice but sometimes simplicity is better.

    • @cassieevans604
      @cassieevans604 Před 6 měsíci

      Not really accurate. The animations shown here were deliberately simple for demo purposes. But GSAP allows for a huge amount that just isn't possible using CSS or framer motion.

    • @shableep
      @shableep Před 5 měsíci

      GSAP provides a lot more control over your animations, especially nested animations that are also dependent on the change of values. If you're doing simpler animations, CSS is the way to go for sure. But GSAP is great for much more complex stuff when you need it.

  • @kamalkhatri-pi8su
    @kamalkhatri-pi8su Před 5 měsíci

    can you make something for angular. I love to work with gsap in angular framework.

    • @GreenSockLearning
      @GreenSockLearning  Před 5 měsíci +1

      Have you used GSAP in angular? Did you have any specific friction points?

    • @kamalkhatri-pi8su
      @kamalkhatri-pi8su Před 5 měsíci

      @@GreenSockLearning I have used but I just want to tell you everyone does not use react. So pls make angular specific video also.it will help angular develpers. Thanks

  • @kabeerfcc4153
    @kabeerfcc4153 Před 5 měsíci

    Hy , mam please recommend me easy book for learning react js . With easy words of English

  • @olatunjiolakunle6908
    @olatunjiolakunle6908 Před 6 měsíci

    Is something like this available in Vue ?

    • @GreenSockLearning
      @GreenSockLearning  Před 5 měsíci

      At the moment we advise using gsap.context() for vue - (which is what this hook uses under the hood) examples here -
      gsap.com/resources/frameworks/

    • @olatunjiolakunle6908
      @olatunjiolakunle6908 Před 5 měsíci

      @@GreenSockLearning thank you.

  • @user-sg4dx3nj2f
    @user-sg4dx3nj2f Před 5 měsíci

    please provide documentation available for French speakers

    • @GreenSockLearning
      @GreenSockLearning  Před 5 měsíci +1

      I'm afraid we only have english docs. Our company is small (three people) and we don't speak french. I'd suggest using a translation extension, www.deepl.com/en/chrome-extension
      If you get stuck we can try and help you in the forums. Sorry we can't help more here.

    • @user-sg4dx3nj2f
      @user-sg4dx3nj2f Před 5 měsíci

      @@GreenSockLearning ok okay, good job to you anyway, I use gsap in all my projects and I am satisfied with the results and the performance that gsap brings ❤ I hope that there will be a French version of the documentation one day 😊

  • @Osuran_Bogaa
    @Osuran_Bogaa Před 6 měsíci

    can i use gsap in react native ?

    • @JackDoyleGS
      @JackDoyleGS Před 6 měsíci

      Sure, I don't see why not. GSAP can animate anything that JavaScript can touch. I have zero experience with React Native personally, but I can't imagine why there'd be a problem.

    • @veedjohnson
      @veedjohnson Před 5 měsíci

      @@JackDoyleGSthere will be a problem because GSap animates html elements.
      How is that going to work with native?

    • @JackDoyleGS
      @JackDoyleGS Před 5 měsíci

      @@veedjohnson GSAP can animate literally anything that JavaScript can touch - not just DOM elements.

    • @veedjohnson
      @veedjohnson Před 5 měsíci

      @@JackDoyleGS might give it a shot can you explain how it will work with the class name references used in the video? Given that react native does not use classes for it's elements

    • @JackDoyleGS
      @JackDoyleGS Před 5 měsíci

      @@veedjohnson I have no knowledge of React Native, sorry. But you can target literally any object that JavaScript can touch, even a generic object like {x: 100}. If you're not dealing with DOM elements, then you wouldn't use selector text for your target - you'd reference the objects themselves whose properties you're animating.

  • @fernandoli6743
    @fernandoli6743 Před 18 dny

    Her voice is so sexy !!!

  • @Labadubadubai
    @Labadubadubai Před 6 měsíci

    Hello Beauty )

  • @linorabolini
    @linorabolini Před 6 měsíci +26

    Its so sad that React is so toxic at this point that we need adapters for everything. React is ruining what programming means and its ruining developers overall. Get out of react, try solidJS and be free.
    edit: I recommend SolidJS here because it is almost 1:1 to react, but without many of the bad parts of React.

    • @adeleke5140
      @adeleke5140 Před 6 měsíci +3

      Could you explain what you mean by toxic?

    • @linorabolini
      @linorabolini Před 6 měsíci +1

      @@adeleke5140 yes ! what I mean by toxic is that React as a library is contaminating everything what was built up to now. If you want to use a 3rd party code, you need to "Reactify" it.
      The community is great, don't take me wrong, but it has gone too far to my taste. Really simple things became difficult, and the quality of our apps has been getting directly affected by it. The need of a special hook to make greensock would be an example. State management in react is another jungle we could talk about, a new library comes out every week.
      Hope this helps clarify my opinion :)

    • @gcash49
      @gcash49 Před 6 měsíci +11

      skill issue

    • @JEsterCW
      @JEsterCW Před 6 měsíci +5

      @@linorabolini lol, from the way how react works its a framework, not library. I would rather pick vue/angular/svelte than solid. Hooks are just wrappers or additional abstraction(function) to make us more productive or comfortable (DX). State management in react is really fine since its hella open. The real problem is using old problematic ass tech like redux, mui or other piece of sheet instead of zustand,ss or just loaders per route. The quality of our app depends on ourselves(always) cuz of architecture and code quality, tool is only a tool it doesnt makes mess for no reason and if do youre using a wrong tool or u hit its limits.

    • @linorabolini
      @linorabolini Před 6 měsíci

      @@gcash49 no, is not that. i have been working with react for the last 7 years. Or more actually. I thought it was the way to go, but i realized how much damage it made recently

  • @wchorski
    @wchorski Před 5 měsíci

    if you're getting a "Cannot use import statement outside a module" on plugin imports, try this
    import { Draggable } from "gsap/dist/Draggable";

  • @Michael-Martell
    @Michael-Martell Před 5 měsíci

    Hey, I'm looking for the GSAP discord server. Could you send an invite so that I may join if it exists?

    • @GreenSockLearning
      @GreenSockLearning  Před 5 měsíci +1

      Hey there! We're considering setting up a discord for club members but it doesn't exist yet. This is a nice animation discord that we have a channel in though - discord.gg/uyVxpuwc8f

    • @Michael-Martell
      @Michael-Martell Před 5 měsíci

      @@GreenSockLearning That would be awesome if and when you do! Thanks for that invite!