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

How can I resolve this error, 'the expected type comes from property 'component' which is declared here on type'. Using TypeScript with React Native

$
0
0

In my code here, I am trying to create a Stack Navigator.

This is the stack navigator I have made.

import React from 'react';import { View, Text, StyleSheet } from 'react-native';import { createStackNavigator } from '@react-navigation/stack';import EnterPassword from '../screens/EnterPassword';import EnterAccount from '../screens/EnterAccount';const GoogleLoginStack = createStackNavigator();const GoogleLogin = () => {    return (<GoogleLoginStack.Navigator><GoogleLoginStack.Screen name='EnterAccount' component={EnterAccount} /><GoogleLoginStack.Screen name='EnterPassword' component={EnterPassword} /></GoogleLoginStack.Navigator>    )};export default GoogleLogin;

It is then used in App.tsx file where:

...<Stack.Screen name="Login" component={Login} /><GoogleLogin /><Stack.Screen name="SignUp" component={SignUp} />...

The screen I have created is as follow:

import React from 'react';import { View, Text, StyleSheet } from 'react-native';const EnterAccount = (props: any) =>  {<View style={styles.screen}><Text>            Enter Account Screen</Text></View>}const styles = StyleSheet.create({    screen: {        flex: 1,        justifyContent: 'center',        alignItems: 'center',    }})export default EnterAccount;

However, I am getting this error:Error text: https://i.stack.imgur.com/zKbAa.png

I understand that it is because of how I defined the type of props to be but I am unsure of what's the right way to define the type of props.

Thank you so much for your help!


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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