title: React Native Functional Component Updates State On Second Submit Only
body: <p>When I console log my values, it updates only if I submit the form the second time. Why is this happening?</p>
  
  <pre><code>const Link = (props) =&gt; {
    const { state, scrape } = useContext(ScrapeContext);
    const [clipboard, setClipboard] = useState();
    const [googleClip, setGoogleClip] = useState(false);
    const [googleLink, setGoogleLink] = useState('');
  
    const urlFromClipboard = () =&gt; {
      Clipboard.getString().then((content) =&gt; {
        if (content.includes('https://www.google.com')){
          setGoogleClip(true);
          console.log('googleLink', googleLink);
          setClipboard(content);
          setGoogleLink(`${content.split('?')[0]}?__a=1`);
        } else {
          setGoogleClip(false);
        }
      });
  
      if (googleClip) {
        console.log(googleLink);
        scrape({ googleLink });
      }
    }
  
    useEffect(() =&gt; {
      urlFromClipboard();
      console.log('useEffect googleLink', googleLink);
      console.log('useEffect state', state);
    }, [clipboard]);
  
  
    return (
      &lt;View style={styles.container}&gt;
        &lt;View style={styles.inputFieldContainer}&gt;
          &lt;TextInput
            style={styles.inputField}
            placeholder='Enter Google url'
            autoCapitalize='none'
            autoCorrect={false}
            value={googleClip ? clipboard : ''}
          /&gt;
        &lt;/View&gt;
        &lt;View style={styles.buttonContainer}&gt;
          &lt;TouchableOpacity
            onPress={() =&gt; {
              urlFromClipboard();
            }}
            style={styles.touchSubmit}
          &gt;
            &lt;Text style={styles.touchText}&gt;Submit&lt;/Text&gt;
          &lt;/TouchableOpacity&gt;
        &lt;/View&gt;
        {state.errorMessage ? (
          &lt;Text style={styles.errorMessage}&gt;{state.errorMessage}&lt;/Text&gt;
        ) : null}
      &lt;/View&gt;
    );
  }
  </code></pre>
  
  <p>What I have here is a component that will grab data from a url, and on submit it will scrape certain information the app needs, however, it will only update those console log values if I press the submit button twice.</p>