Skip to content

Instantly share code, notes, and snippets.

@borillo
Created April 7, 2015 19:05
Show Gist options
  • Save borillo/705123948e706c55c9fe to your computer and use it in GitHub Desktop.
Save borillo/705123948e706c55c9fe to your computer and use it in GitHub Desktop.
Side menu integration with react-native
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
Caption,
MenuItem
} = React;
var SideMenu = require('react-native-side-menu');
var ContentView = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+Control+Z for dev menu
</Text>
</View>
);
}
});
var Menu = React.createClass({
about: function() {
this.props.menuActions.close();
},
render: function() {
return (
<View>
<Caption>Menu</Caption>
<MenuItem onPress={this.about}>About</MenuItem>
</View>
);
}
});
var catalogo = React.createClass({
render: function() {
var menu = <Menu navigator={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,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('catalogo', () => catalogo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment