azazdeaz / react-gsap-enhancer

Use the full power of React and GSAP together
MIT License
727 stars 38 forks source link

Animating Custom Components #38

Closed codytooker closed 7 years ago

codytooker commented 7 years ago

All the examples seem to show animating default tags like, div, span, h1, etc. How do we go about animations on our custom components. I found an old issue that mentions refs but I am not sure exactly how to target the element in order to run the animations.

for instance, I have something like the following

`

<FullSection name="section-1" ref={ comp => this.sectionOne = ReactDOM.findDOMNode(comp) }>

Share
    </FullSection>
  </div>`

how do I then find section-1 in order to use it?

const section = target.find({name: 'section-1'});

That doesn't seem to work.

codytooker commented 7 years ago

I think I figured it out. finding the DOMNode doesn't work with stateless components so just had to go change my components to Class components instead of functional components.