Jump to content
Search Community

Help with DrawSvgPlugin

PhoenixNile test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I current signed up and bought the package to become a club house member, I love what you guys do and wanted to show my support! So I have been working on my React Portfolio Website recently and used the DrawSVGPlugin, I installed the zip file and everything works on my localhost, but when I deployed to Netlify it doesn't show up. When I inspect the page using the dev tools I see my image and logo outline are there but hidden. I have attached bellow the code and pictures from the localhost and live site any help will be much appreciated thank you in advanced!!1206017560_LocalHostReactPortfolio.thumb.jpeg.16c060dae77f4b45884a4bcd80cb4f22.jpeg1144050664_LiveReactPortfolio.thumb.jpeg.e3506e9462f9ffd8ab2803de2eb1aaaa.jpeg1162446074_Logo.jsCodePart1.thumb.jpeg.cb21f4b878106c505f28ef5af72371cd.jpeg841113895_Logo.jsCodePart2.thumb.jpeg.ba153f29e8b17f3bce6bf74d6c8118bd.jpeg1981028439_Logo.jsCodePart3.thumb.jpeg.39a3a85449e01e77012e7bd1ce9ea4ce.jpeg2108739148_Logo.scssCode.thumb.jpeg.ca8a820f75863ed514cd1529f06dabdf.jpeg

Link to comment
Share on other sites

  • Solution

Yep, @elegantseagulls seems exactly right. From what I see, you're actually trying to create your tweens inside a cleanup function. You should created it inside the useEffect() or useLayoutEffect() normally, and then revert it in the cleanup function. 

 

Keep in mind that in React 18+ calls useEffect() TWICE in strict mode (which is the default in local development) so it's critical to do proper cleanup in order to avoid creating multiple conflicting animations. In your demo, it probably worked BECAUSE of the odd double-call to useEffect() since it called the cleanup function once but the useEffect() twice. 

 

gsap.context() is your new best friend in React - it makes cleanup super easy and also allows you to use scoped selector text. Please read this article: 

 

So just use a gsap.context() and do proper cleanup: 

 useEffect(() => {
   let ctx = gsap.context(() => {
     // put all your GSAP/ScrollTrigger code inside here...
   });
   return () => ctx.revert(); // <-- CLEANUP!
 }, []);

Does that resolve things? If not, please provide a CodeSandbox or Stackblitz illustrating the problem and we'd be happy to take a peek. But I bet the issue is just not doing proper cleanup. Here are some React starter templates with GSAP: 

https://stackblitz.com/@GreenSockLearning/collections/gsap-react-starters

 

And thanks for signing up for Club GreenSock to show your support! 💚🥳

 

Happy tweening!

  • Like 2
Link to comment
Share on other sites

 useEffect(() => {
   let ctx = gsap.context(() => {
     // put all your GSAP/ScrollTrigger code inside here...
   });
   return () => ctx.revert(); // <-- CLEANUP!
 }, []);

This worked!! Thank you so much for sharing the docs with me and reaching back out so quickly!

  • Like 2
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...