Last active
August 28, 2017 18:23
-
-
Save dk0r/8916d8b946642ae8c8be63212f61b3da to your computer and use it in GitHub Desktop.
Receiving error that `this.props.drawer` is undefined: http://i.imgur.com/uEtsvEH.png
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TabNavigator } from 'react-navigation' | |
export const Tabs = TabNavigator( | |
{ | |
Home: { | |
screen: Container, | |
navigationOptions: { | |
tabBarLabel: 'Home', | |
tabBarIcon: ({ tintColor }) => | |
<Icon name="ios-home" size={28} color={tintColor} /> | |
} | |
} | |
}, | |
{ | |
tabBarPosition: 'bottom', | |
//swipeEnabled: false, | |
tabBarOptions: { | |
showIcon: true, | |
showLabel: false, | |
activeTintColor: '#fff8e6', | |
style: { | |
backgroundColor: 'black' | |
}, | |
tabStyle: { | |
height: dims.navBarHeight //Tested that minimum height for navBar is 24 | |
}, | |
indicatorStyle: { | |
backgroundColor: '#ffc423' | |
} | |
} | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Container extends Component { | |
render() { | |
openDrawer = () = > { | |
this.drawer.openDrawer() | |
alert('Drawer opened!!') | |
} | |
return ( | |
<DrawerLayout | |
//Remeber that ref receives the <DrawerLayout> component as it's input | |
//more details @ https://facebook.github.io/react/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element | |
ref={e => (this.drawer = e)} | |
drawerWidth={300} | |
drawerPosition={DrawerLayout.positions.Left} | |
//Below renders the content contained within the sliding drawer | |
renderNavigationView={() => | |
<DrawerContent {...this.props} />} | |
drawerLockMode={'locked-closed'} | |
> | |
{/* This is the main screen (containing the button to open the drawer) */} | |
<Home openDrawer={this.openDrawer} /> | |
</DrawerLayout> | |
) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Home extends Component { | |
render() { | |
return ( | |
<DrawerButton {...this.props} size={100} /> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment