0

This error occurs while using navigation. I don't understand why you do that. The above error occurs when trying to navigate from HomeScreen to SignUp Detail through navigation. I've looked everywhere, but I'm asking because I can't find the answer. This error occurs while using navigation. I don't understand why you do that. The above error occurs when trying to navigate from HomeScreen to SignUp Detail through navigation. I've looked everywhere, but I'm asking because I can't find the answer.

this code App.js




import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";

import SignUp from "./components/signupdetail/signup";
import HomeScreen from "./components/homeScreen";

const Stack = createStackNavigator();

const App = () => {

  return (
    <>
      <NavigationContainer>
        <Stack.Navigator initialRouteName="Home">
          <Stack.Screen name="Home" component={HomeScreen} />
          <Stack.Screen name="SignUp" component={SignUp} /> //my problem
        </Stack.Navigator>
      </NavigationContainer>
    </>
  );
};

export default App;

this code Homescreen


import Login from "./loginScreen/login";
import ButtonComponent from "./loginScreen/button";
import LostPassword from "./loginScreen/lostpassword";
import SocialLogin from "./loginScreen/sociallogin";
import SignUp from "./loginScreen/signup";
const HomeScreen = (props) => {
 

  return (
    <>
      <SafeAreaView style={styles.container}>
        <Text style={styles.header}>everywear</Text>
      </SafeAreaView>
      <View>
        <Login />
        <ButtonComponent />
        <LostPassword />
        <SocialLogin />
        <SignUp navigation={props} />
      </View>
    </>
  );
};

export default HomeScreen;

this code signup


import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";

const SignUp = (props) => {
 
  const { navigation } = props;
  return (
    <>
      <View style={styles.container}>
        <Text style={styles.text}>혹시 처음이신가요?</Text>
        <TouchableHighlight
          onPress={() => {
            navigation.navigate("SignUp");
          }}
          underlayColor="gray"
          style={styles.button}
        >
          <>
            <Text style={styles.signuptext}>회원가입</Text>
          </>
        </TouchableHighlight>
      </View>
    </>
  );
};

export default SignUp;

1 Answer 1

3

There are different ways to fix this issue.

Easiest one would be to change like below

 <SignUp navigation={props.navigation} />

This will pass the navigation prop correctly and the rest of the code would work as expected.

  1. the useNavigation hook

you can use the hook like below

const SignUp = (props) => {
 
  const navigation = useNavigation();

then no need to pass the prop from the parent.

Sign up to request clarification or add additional context in comments.

1 Comment

You are welcome :) , please mark the answer if it solves your issue :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.