title: RESOLVED React navigation not working react native
body: <p>I am just giving a console.log (data) and navigating to another screen.</p>
  <p>but I'm having the following error:</p>
  <p>Component Exception
  undefined is not an object</p>
  <p>what am I doing wrong?</p>
  <p>NOTE: When I use, navigation.goBack() works.</p>
  <p>code below;</p>
  <p>the error persists</p>
  <p>Can anyone help me??</p>
  <p><strong>CODE UPDATED</strong></p>
  <pre><code>import React, { useRef } from 'react';
  import { useNavigation } from '@react-navigation/native';
  import { Form } from '@unform/mobile';
  import {
    KeyboardAvoidingView,
    Platform,
    ScrollView,
    Image,
  } from 'react-native';
  
  import logo from '../../assets/logo.png';
  
  import Input from '../../components/Input';
  import Button from '../../components/Button';
  
  import { Container, FormContainer, Title, TitleContainer } from './styles';
  
  export default function SignUp() {
    const formRef = useRef(null);
  
    const navigation = useNavigation();
  
    const handleSignUp = data =&gt; {
      console.log(data);
      navigation.navigate('SignUpPersonalData', { data });
    };
  
    return (
      &lt;&gt;
        &lt;KeyboardAvoidingView
          style={{ flex: 1 }}
          behavior={Platform.OS === 'ios' &amp;&amp; 'padding'}
          enabled
        &gt;
          &lt;ScrollView keyboardShouldPersistTaps=&quot;handled&quot;&gt;
            &lt;Container&gt;
              &lt;Image source={logo} /&gt;
  
              &lt;TitleContainer&gt;
                &lt;Title&gt;Crie sua conta&lt;/Title&gt;
              &lt;/TitleContainer&gt;
  
              &lt;Form ref={formRef} onSubmit={handleSignUp}&gt;
                &lt;Input
                  autoCorrect={false}
                  autoCapitalize=&quot;none&quot;
                  keyboardType=&quot;email-address&quot;
                  name=&quot;email&quot;
                  icon=&quot;mail&quot;
                  placeholder=&quot;E-mail&quot;
                /&gt;
  
                &lt;Input
                  secureTextEntry
                  returnKeyType=&quot;send&quot;
                  name=&quot;password&quot;
                  icon=&quot;lock&quot;
                  placeholder=&quot;Senha&quot;
                /&gt;
  
                &lt;Button onPress={() =&gt; formRef.current.submitForm()}&gt;
                  Continuar
                &lt;/Button&gt;
              &lt;/Form&gt;
            &lt;/Container&gt;
          &lt;/ScrollView&gt;
        &lt;/KeyboardAvoidingView&gt;
      &lt;/&gt;
    );
  </code></pre>
  <p>Screenshot error:</p>
  <p><a href="https://i.stack.imgur.com/oOOcN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oOOcN.jpg" alt="error" /></a></p>
  <p>SX</p>