ReactNavigation: Problem with calling navigation

Viewed 4235

I have an error with my code

export default function SignIn({ navigation }) {
  const [destination, setDestiantion] = useState("");
  return (
    <View>
      <TextInput
        onChangeText={value => {
          typedText(value);
          setDestiantion(value === "Employee" ? "SignUp1" : "SignUp2");
        }}
        value={text}
      />
      <TouchableOpacity onPress={() => navigation.navigate({ destination })} />
    </View>
  );
}

But my simulator said:

while calling navigate with an object as the argument you need to specify name or key.

Someone help me please, thank you very much.

2 Answers
<TouchableOpacity onPress={()=>navigation.navigate({destination})}/>

Replace with

<TouchableOpacity onPress={()=>navigation.navigate("destination")}/>

Insted of this : <TouchableOpacity onPress={()=>navigation.navigate({destination})}/>

use it like this : <TouchableOpacity onPress={()=>navigation.navigate(destination)}/>

a destination with out the { } braces

Related