Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6213

React navigation 5 error Binding element 'navigation' implicitly has an 'any' type.ts

$
0
0

I am new to react-native. I am trying to implement navigation using react-navigation 5. I have two screens Home and profile. These both components have received a navigation prop but typescript is giving me follwoing error

Binding element 'navigation' implicitly has an 'any' type.ts(7031)

How to get rid of this error.

Thank you in advance

NOTE - I am using typescript

App.tsx

import 'react-native-gesture-handler';import { NavigationContainer } from '@react-navigation/native';import { createStackNavigator } from '@react-navigation/stack';const Stack = createStackNavigator();import Home from './screens/home'const App  = () => {  const ProfileScreen = ({}) => {    return <Text>This is Jane's profile</Text>;  };  return (<NavigationContainer><Stack.Navigator><Stack.Screen          name="Home"          component={Home}        /><Stack.Screen name="Profile" component={ProfileScreen} /></Stack.Navigator></NavigationContainer>  );};

Home.tsx

import React from 'react';import { Button } from 'react-native';const Home = ({navigation}) =>{ // error  return (<Button    title="Go to Jane's profile"    onPress={() =>      navigation.navigate('Profile', { name: 'Jane' })    }  />  )}export default Home;

Viewing all articles
Browse latest Browse all 6213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>