Skip to content

Instantly share code, notes, and snippets.

@dk0r
Last active August 25, 2017 18:17
Show Gist options
  • Save dk0r/f73ff2fc5965929b9fb7efad9822b2a3 to your computer and use it in GitHub Desktop.
Save dk0r/f73ff2fc5965929b9fb7efad9822b2a3 to your computer and use it in GitHub Desktop.
Line-30's onPress() produces error: undefined is not an object (evaluating '_this2.drawer.openDrawer')
import React, { Component } from 'react'
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'
import DrawerLayout from 'react-native-drawer-layout'
export default class Drawer extends Component {
constructor(props) {
super(props)
this.state = {}
}
render() {
let navigationView = (
<View style={{ flex: 1, backgroundColor: '#fff' }}>
<Text style={{ margin: 10, fontSize: 15, textAlign: 'left' }}>
I'm in the Drawer
</Text>
</View>
)
return (
<DrawerLayout
drawerWidth={300}
drawerPosition={DrawerLayout.positions.Left}
renderNavigationView={() => navigationView}
>
<View style={{ flex: 1, alignItems: 'center' }}>
<TouchableOpacity
onPress={() => this.drawer.openDrawer()}
style={{ backgroundColor: 'magenta' }}
>
<Text>Press Me!</Text>
</TouchableOpacity>
</View>
</DrawerLayout>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment