我有一个react-native应用程序,我得到了以下问题。这是错误信息
我的依赖性如下
"dependencies": {
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/native": "^5.1.6",
"@react-navigation/stack": "^5.2.13",
"react": "16.11.0",
"react-native": "^0.62.2",
"react-native-gesture-handler": "^1.6.1",
"react-native-reanimated": "^1.8.0",
"react-native-router-flux": "^4.2.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.5.0",
"react-navigation": "^4.3.8",
"react-navigation-stack": "2.0.15"
},
我的App.js
const LoginStack = createStackNavigator(
{
Login: Login,
// Register: RegisterScreen,
},
{
initialRouteName: 'Login',
headerMode: "none"
}
)
const Navigator = createSwitchNavigator(
{
LoginSwitch: LoginStack,
AuthLoading: SplashScreen
},
{
initialRouteName: 'LoginSwitch',
headerMode: 'none'
}
)
export default createAppContainer(Navigator)
我的index.js
import React from 'react'
import { AppRegistry } from 'react-native';
import 'react-native-gesture-handler'
import { name as appName } from './app.json';
import SplashScreen from './src/utils/splashScreen'
import App from './src/App'
AppRegistry.registerComponent(appName, () => App);
如果我把splash放在initialRoute中,它就会工作,但如果我把登录放在里面,它就不会工作。
屏幕登录
class Login extends Component {
render() {
return (
<View style={{flex: 1}}>
<Text>Teste</Text>
<Text>Teste</Text>
<Text>Teste</Text>
</View>
)
}
}
export default Login
试着通过以下两步中的任何一步进行手动链接。进入你的项目文件夹,并将此添加到你的 pod 文件中。
pod 'react-native-safe-area-context', :path => '../node_modules/react-native-safe-area-context'
//Then Do this on the terminal
cd ios/
pod install
或
react-native link react-native-safe-area-context
这将解决这个问题