Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 在React Native中的自定义抽屉组件中隐藏抽屉_React Native_React Native Navigation - Fatal编程技术网

React native 在React Native中的自定义抽屉组件中隐藏抽屉

React native 在React Native中的自定义抽屉组件中隐藏抽屉,react-native,react-native-navigation,React Native,React Native Navigation,SideMenu是我的自定义抽屉组件,其中有X按钮 当我按下X按钮时,我想关闭抽屉 我如何才能做到这一点?您想使用toggleDrawer()。非常基本的例子: render() { const { navigator } = this.props return ( <Button onPress={() => navigator.toggleDrawer({ side: 'right', animated: true })} /> ) }

SideMenu
是我的自定义抽屉组件,其中有
X
按钮

当我按下
X
按钮时,我想关闭抽屉


我如何才能做到这一点?

您想使用
toggleDrawer()
。非常基本的例子:

render() {
  const { navigator } = this.props

  return (
    <Button
      onPress={() => navigator.toggleDrawer({ side: 'right', animated: true })} />
  )
}
render(){
const{navigator}=this.props
返回(
toggleDrawer({side:'right',动画:true})}/>
)
}

您想使用
toggleDrawer()
。非常基本的例子:

render() {
  const { navigator } = this.props

  return (
    <Button
      onPress={() => navigator.toggleDrawer({ side: 'right', animated: true })} />
  )
}
render(){
const{navigator}=this.props
返回(
toggleDrawer({side:'right',动画:true})}/>
)
}

您可以使用this.props.navigation.closeDrawer()或this.props.navigation.toggleDrawer()进行此操作

<Button onPress={()=>this.props.navigation.closeDrawer()} />
this.props.navigation.closeDrawer()}/>

this.props.navigation.toggleDrawer()}/>

您可以使用this.props.navigation.closeDrawer()或this.props.navigation.toggleDrawer()进行此操作

<Button onPress={()=>this.props.navigation.closeDrawer()} />
this.props.navigation.closeDrawer()}/>

this.props.navigation.toggleDrawer()}/>