title: GSAP target undefined not found
body: <p>With useSate I toggle between two paragraphs of text from french to english. It works fine but I want to set up a nicer transition with GSAP.</p>
  <p>My configuration doesn't work because the gsap target is null or undefined.
  Can you help me to debug that problem?</p>
  <p>The paragraph component with the two buttons :</p>
  <pre><code>      import React, { useRef, useState } from &quot;react&quot;;
  import { withRouter } from &quot;react-router-dom&quot;;
  import gsap from 'gsap';
  
  const LanguageDesc = (props) =&gt; {
  
      const [state, setState] = useState({
          isActive: false,
          languageName: 'English'
      });
  
      let english = useRef(null);
      let french = useRef(null);
  
      const handleLanguage = () =&gt; {
          if (state.isActive === false) {
              setState({
                  isActive: true,
                  languageName: 'French'
              })
              gsap.from(english.current, {
                  duration: 5,
                  opacity: 0,
              })
          } else if (state.isActive === true) {
              setState({
                  isActive: false,
                  languageName: 'English'
              })
              gsap.from(french.current, {
                  duration: 1,
                  opacity: 0,
              });
          } else if (state.isActive === false) {
              setState({
                  isActive: !state.isActive,
                  languageName: 'French'
              })
              gsap.from(english.current, {
                  duration: 5,
                  opacity: 0,
              })
          }
      };
  
  
      return (
          &lt;div&gt;
              {state.isActive ?
                  &lt;p ref={english} className=&quot;eng-text&quot;&gt;{props.state.desc_en}&lt;/p&gt;
                  : null}
              {state.isActive ?
                  null
                  : &lt;p ref={french} className=&quot;fr-text&quot;&gt;{props.state.desc_fr}&lt;/p&gt;}
              &lt;button className=&quot;btn-language&quot; onClick={handleLanguage} &gt; {state.languageName} text&lt;/button&gt;
          &lt;/div &gt;
      )
  
  };
  export default withRouter(LanguageDesc);
  </code></pre>
  <p><a href="https://i.stack.imgur.com/rI6No.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rI6No.png" alt="console" /></a></p>