2017-04-06 59 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')