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

Pass props from App class to const function React Typescript

$
0
0

Im trying to create an React Native App with Expo.I have a logical error passing props from App class to my Component "Navigator" type const function.Im not sure how i must to pass the props or how i must to access to them without passing from App:

App.tsx

import React, {useState} from 'react';import { NavigationContainer, StackActions } from '@react-navigation/native';import Navigator from './Components/Navigator';export default class App extends React.Component {  render(){   return (<NavigationContainer><Navigator props={this.props}/></NavigationContainer>   );  }}

Navigator.tsx

import React from 'react'import { createStackNavigator } from '@react-navigation/stack'import Login from '../Views/Login'import Home from '../Views/Home'const Stack = createStackNavigator();function Navigator({props}){  return (<Stack.Navigator><Stack.Screen name="Login" options={{title:'Login.'}}>                {(props) => <Login {...props} />}</Stack.Screen><Stack.Screen name="Home" component={Home} options={{title:'Home.'}}/></Stack.Navigator>  );}export default Navigator;

I have error undefined is not an object (props)


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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