undefined is not an object (evaluating 'route.params.id')

3339 views react-native

i have created two component in the first component I have an object and I want to display on the the other screen component I passed it as parameter but when I liked it through error here is my code

const Tweets = ({ navigation }) => (
      title="View Tweet"
      onPress={() => navigation.navigate("TweetDetails", { id: 1 })}

const TweetDetails = ({ route }) => (
    <Text>Tweets details {route.Params.id}</Text>

const Stack = createStackNavigator();
const StackNavigator = () => (
  <Stack.Navigator initialRouteName="Tweets">
    <Stack.Screen name="Tweets" component={Tweets} />
    <Stack.Screen name="TweetDetails" component={TweetDetails} />

export default function App() {
  return (
      <StackNavigator />

enter image description here

answered question

why is your params capital? like P in their capital

thanks issue of capital p

params not Params. It is not capital, Also you need control it too: <Text>Tweets details {route?.params?.id}</Text>

1 Answer


I believe the issue is like P is capital in your params.

Hopeit helps. feel free for doubts

posted this

Have an answer?


Please login first before posting an answer.