2017-04-06 121 views
0

o/打开react-native-side onPress

我最近开始使用react-native进行游戏并制作了几个较小的测试应用程序。 我最近的项目应该包括一个侧边栏菜单,并且我react-native-sidebar。但是,我似乎无法弄清楚我是如何打开边栏的 - 可悲的是,他们的文档没有提供任何有关任何信息。

代码:

renderLeftSidebar() 
{ 
    return <Text>LEFT SIDE BAR CONTENT</Text>   
} 

renderContent() 
{ 
    return(<Button onPress={___OPEN__SIDEBAR___}><Text>Open Sidebar</Text></Button>) 
} 

render() { 
    return (
     <Sidebar leftSidebar   = { this.renderLeftSidebar() } 
       open    = 'left' 
       style    = {styles.leftSidebarContainer}> 
      { this.renderContent() } 
     </Sidebar> 
    ) 
} 

const styles = StyleSheet.create({ 

leftSidebarContainer: 
{ 
    flex: 1, 
}, 
}); 

,因为我设置侧边栏打开=“左”它开始开放,但我怎么改变它 - 所以,当我按下按钮,它只是open'ed?

回答

0

想通了我自己,我必须设置侧边栏的引用:

ref = {(c) => this._leftsidebar = c} 

,然后只要致电:

this._sidebar.open('left')