我有一个初学者的问题。 我正在尝试使用react导航创建路线系统,创建了StackNavigator,但是出现了一个对我来说意义不大的错误
我在Android上使用React-Navigation 3.x和React-native 0.59
routes.js
import { createAppContainer, createStackNavigator } from 'react-navigation';
import HomeScreen from './screens/Home'
const Routes = createStackNavigator({
Home: HomeScreen,
})
export default createAppContainer(Routes)
Home.js
import React, { Component } from 'react'
import { Text, View } from 'react-native'
export default class Home extends Component {
render() {
return (
<View>
<Text>Hello</Text>
</View>
)
}
}
index.js(src)
import React, { Component } from 'react'
import Routes from './routes'
export default class App extends Component {
render () {
return <Routes />
}
}
index.js(根目录)
import {AppRegistry} from 'react-native';
import App from './src';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);
控制台日志
ReferenceError: ReferenceError: View is not defined
This error is located at:
in NavigationContainer (at src/index.js:9)
in App (at renderApplication.js:35)
in RCTView (at View.js:45)
in View (at AppContainer.js:98)
in RCTView (at View.js:45)
in View (at AppContainer.js:115)
in AppContainer (at renderApplication.js:34)