Skip to content

Instantly share code, notes, and snippets.

@TiagoGouvea
Created October 10, 2015 16:12
Show Gist options
  • Select an option

  • Save TiagoGouvea/ba30975dd125d8a358ae to your computer and use it in GitHub Desktop.

Select an option

Save TiagoGouvea/ba30975dd125d8a358ae to your computer and use it in GitHub Desktop.
Sample DrawerLayout opened by clicking in a TouchableHighlight component
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
DrawerLayoutAndroid,
TouchableHighlight,
} = React;
var DrawerTest = React.createClass({
openDrawer:function() {
this.refs['DRAWER'].openDrawer()
},
render: function() {
var navigationView = (
<View style={{flex: 1, backgroundColor: '#fff'}}>
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>I'm in the Drawer!</Text>
</View>
);
return (
<DrawerLayoutAndroid
drawerWidth={300}
ref={'DRAWER'}
drawerPosition={DrawerLayoutAndroid.positions.Left}
renderNavigationView={() => navigationView}>
<View style={{flex: 1, alignItems: 'center'}}>
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>Hello</Text>
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>World!</Text>
<TouchableHighlight onPress={this.openDrawer}>
<Text>{'Open Drawer'}</Text>
</TouchableHighlight>
</View>
</DrawerLayoutAndroid>
);
}
});
AppRegistry.registerComponent('DrawerTest', () => DrawerTest);
@Keshava11

Copy link
Copy Markdown

@ajeshekl Thanks. Worked for me. Is it due to change in ES standard ?

@shiundu

shiundu commented Jan 10, 2018

Copy link
Copy Markdown

Thanks @yashvekaria for raising the issue and @lalkmim and @ajeshekl for the solution!

@shures

shures commented Mar 25, 2019

Copy link
Copy Markdown

I got an issue, it shows only shadows when clicking the bottom
but shows navigation view when swiped from left

@JexelJimenez

Copy link
Copy Markdown

I got an issue, it shows only shadows when clicking the bottom
but shows navigation view when swiped from left

same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment