Skip to content Skip to sidebar Skip to footer

Gsap With React.js

I encounter this problem. I use GSAP in react project to do some complicated animation. I want to ask that how can I clear the style applied on the DOM whenever the component re-re

Solution 1:

You should read a bit about react before using it

https://reactjs.org/tutorial/tutorial.html#what-is-react

but answering your question, first you don't need to use jquery

How to add scroll event in react component

this.state should only contain "state" the state of the view, things that are used in the render function, everytime you call setState the view will be re-rendered so you can use setState to change the style, in your case looks like you need to change the style based on timeLineMax, you should grab the value that you wanna change from timeLineMax and use setState of this particular value you shouldn't save tl on the state.

just one more thing javascript uses camelCase for functions not snake_case

http://www.j-io.org/Javascript-Naming_Conventions

Solution 2:

If someone is looking to do something like this today, with GSAP 3 and state hooks, here is a working example on github:

https://github.com/npinos/cloud-animations-react-gsap

Post a Comment for "Gsap With React.js"