Я прочитал некоторые решения, связанные с этой ошибкой, но не использовал это.Большинство из них получают одну и ту же ошибку по разным причинам.Я своего рода новичок в React-Native.Поэтому, пожалуйста, помогите мне!
App.js
import loginScreen from './components/Login';
import React from 'react'
import {createStackNavigator} from 'react-navigation-stack';
import {createAppContainer} from 'react-navigation';
import homeScreen from "./HomeScreen";
import LoadingScreen from "./components/LoadingScreen";
import SignUpScreen from "./components/SignUpScreen";
import StarterScreen from "./components/starter";
import ShoppingCartIconScreen from './components/ShoppingCartIcon';
import SummeryScreen from './components/summery'
const MainNavigator=createStackNavigator(
{
signup:{screen:SignUpScreen},
login:{screen:loginScreen},
Loading: {screen: LoadingScreen },
Summery:{screen:SummeryScreen}, //exporting the Summery component
Starter:{screen:StarterScreen,
navigationOptions:{
title:'Starters',
headerRight:<ShoppingCartIconScreen/>,//using as a icon on the navigation header.
headerStyle:{
backgroundColor:'#694fad'
},
headerTitleStyle:{
color:'white'
}
}},
Home: { screen: homeScreen,
navigationOptions:{
headerTitle:'Home',
headerRight:<ShoppingCartIconScreen/>,
headerStyle:{
backgroundColor:'#694fad',
},
headerTitleStyle:{
color:'white'
}
}}
},
{
initialRouteName:"Home" //set home as a default screen
}
);
const App=createAppContainer(MainNavigator);
export default App; //exporting App.js with stack navigator
ShoppingCartIcon.js
import React from 'react';
import {View,Text,StyleSheet,Platform} from 'react-native';
import Icon from '@expo/vector-icons/Ionicons'
//creating a constant
const ShoppingCartIcon = (props) => (
<View style={[{ padding: 5 }, Platform.OS == 'android' ? styles.iconContainer : null]}>
<View style={{
position: 'absolute', height: 20, width: 20, borderRadius: 15, backgroundColor: '#e3e3e3', right: 6, bottom: 29, alignItems: 'center', justifyContent: 'center', zIndex: 2500,
}}>
<Text style={{ color: 'black', fontWeight: 'bold' }}>0</Text>
</View>
<View style={{top:3}}>
<Icon onPress={()=>props.navigation.navigate("Summery")} name="ios-cart" size={35} color='yellow' /> //navigate to summery screen on icon press
</View>
</View>
)
export default ShoppingCartIcon; //exporting shoppingcarticon
Summery.js // просто фиктивный импорт файла, StyleSheet} от 'Reaction-native'
//nothing special here
export default class summery extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>summery page</Text>
</View>
)
}
}