问候......今天我已经为ReactNAtive创建了一个新项目...并尝试执行抽屉示例......它向我展示了我在标题中指定的这个错误... 这是我的代码......请帮助解决这个错误...
1)使用react-native init hworld创建项目 2)npm for npm install --save react-navigation npm install --save native-base npm install --save react-native-drawer
MY INDEX.JS FILE CODE
import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('hworld', () => App);
3)创建了新文件夹' hw'和文件AppContainer.js
import React, { Component } from 'react';
import Drawer from 'react-native-drawer';
import { View } from 'react-native';
import {Navigator} from 'react-navigation';
import {
Platform,
StyleSheet,
Text
} from 'react-native';
export default class AppContainer extends Component{
constructor(props) {
super(props)
this.state = {
toggled: false,
store: {},
theme: null
}
}
toggleDrawer() {
this.state.toggled ? this._drawer.close() : this._drawer.open()
}
openDrawer() {
this.setState({toggled: true})
}
closeDrawer() {
this.setState({toggled: false})
}
renderScene(route, navigator) {
switch(route) {
default: {
return null
}
}
}
configureScene(route, routeStack) {
return Navigator.SceneConfigs.PushFromRight
}
render() {
return (
<Drawer
ref={(ref) => this._drawer = ref}
type="displace"
content={<View style={{backgroundColor: "#000", height: 1000}}/>}
onClose={this.closeDrawer.bind(this)}
onOpen={this.openDrawer.bind(this)}
openDrawerOffset={0.2}
>
<Navigator
ref={(ref) => this._navigator = ref}
configureScene={this.configureScene.bind(this)}
renderScene={this.renderScene.bind(this)}
/>
</Drawer>
)
}
/*render() {
return (
<View>
<Text>
Welcome to React Native!
</Text>
</View>
);
}*/
}
4)App.js文件代码
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
import AppContainer from './hw/AppContainer';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' +
'Cmd+D or shake for dev menu',
android: 'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
export default class App extends Component<{}> {
render() {
return (
<AppContainer/>
);
}
}