native-side-menu 这是我的代码:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
var React = require('react-native');
var SideMenu = require('react-native-side-menu');
var {
AppRegistry,
StyleSheet,
Text,
View,
Navigator,
} = React;
var ContentView = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
</View>
);
}
});
var TestView = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to another page.
</Text>
<Text style={styles.instructions}>
Testing react native side menu with navigator.
</Text>
</View>
);
}
});
var Menu = React.createClass({
about: function() {
this.props.menuActions.close();
this.props.navigator.push({
component: TestView,
title: 'Test View',
});
},
render: function() {
return (
<View style={styles.sidemenu}>
<Text style={styles.paddingMenuItem}>Menu</Text>
<Text onPress={this.about} style={styles.paddingMenuItem}>About</Text>
</View>
);
}
});
var FindWisely = React.createClass({
render: function() {
return (
<Navigator
initialRoute={{
component: Something,
title: 'Something',
}}
configureScene={() => {
return Navigator.SceneConfigs.FadeAndroid;
}}
renderScene={(route, navigator) => {
if(route.component) {
return React.createElement(route.component, { navigator });
}
}}/>
);
}
});
var Something = React.createClass({
render: function() {
var menu = <Menu navigator={this.props.navigator}/>;
return (
<SideMenu menu={menu}>
<ContentView/>
</SideMenu>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
sidemenu: {
paddingTop: 50,
},
paddingMenuItem: {
padding: 10,
},
});
module.exports = FindWisely;
当我运行这个程序时,我得到了以下错误信息:
“未定义的错误:无法获取对象(评估'this.props.menuActions.close')”