如何在反应材料 UI 主题中单击关闭抽屉? [英] How to close drawer on click in react material UI theme?

查看:29
本文介绍了如何在反应材料 UI 主题中单击关闭抽屉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 React Material 设计主题

I am using react material design theme

但是当我点击移动视图上的抽屉导航按钮时,它不会自动关闭

but when i click drawer navigation button on mobile view it is not closing automatically

喜欢(onClick={handleClose})

如何为我的抽屉导航菜单解决这个问题???

how can i fix this issue for my drawer navigation menu???


</抽屉>);};Navigation.propTypes = { className: PropTypes.string, onClose:PropTypes.func,打开:PropTypes.bool.isRequired,变体:PropTypes.string.isRequired };导出默认导航;

推荐答案

我认为您在父组件上缺少一些东西是 onClose 实现或打开状态,但父组件必须看起来像:

I think you missing something on parent component is either onClose implementation or open state, but parent component has to look like:

state = {
  open: false
}

onClose = () => {
 this.setState({ open: false });
}

render() {
 const { open } = this.state;
 return (
  <Navigation open={open} onClose={this.onClose} {...this.props} />
 )
}

这篇关于如何在反应材料 UI 主题中单击关闭抽屉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆