javascript - React Native - 如何在 View 上实现模式?

标签 javascript reactjs react-native modal-dialog

根据标题,我希望在单击 View 时打开一个模式

app.js

<View>
    <MediaBar onClick={this.toggleModal}> />

      <Modal show={this.state.isOpen}
      onClose={this.toggleModal}>
      `Here's some content for the modal`
    </Modal>
 </View>

Mediabar.js:https://pastebin.com/6bW5gz99

modal.js:https://pastebin.com/3vQgLyTg

最佳答案

模态组件有一个 visible 属性。

https://facebook.github.io/react-native/docs/modal.html

您只需使用父组件状态更新其值即可。

关于javascript - React Native - 如何在 View 上实现模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47396132/

相关文章:

javascript - 制表符日期格式

javascript - 从 react 中的输入字段获取值

reactjs - 如何设置material-ui持卡人头像?

javascript - 在 React 应用程序中使用 npm 包

javascript - 如何更改数组中对象的第一个 bool 值 react native ?

javascript - Prop (对象列表)更新后 react 不渲染

react-native - 如何在 react-native 中创建渐变文本

javascript - 状态更改授权组件后, native 渲染 View 不会更新

javascript - 如何理解这个语法? var {...} = react ;

javascript - 使用 Javascript 将 CSV 文件读入键值对数组