模态前面的模态反应原生,而不是拾取状态

问题描述 投票:0回答:1

我正在使用react-native的Modal组件来创建一个供用户选择的上拉菜单。这个问题是,如果你想调暗背景并用'幻灯片'制作动画,它就会在屏幕上滑动一个暗淡的盒子,而不是使整个背景变暗然后滑动视图。

所以我试图通过使用两个模态来解决这个问题。淡入淡出背景的一种模式和带有透明背景的菜单滑入的第二种模式。

这实际上有效,但是当this.doneDayPicker改变this.state.showModalDayPicker的状态以便两个模态不再可见时,<DarkModal>仍然出现。我在屏幕上永久地留下了<DarkModal>

当qazxsw poi改变时,我能改变什么来让qazxsw poi消失?

<DarkModal>
react-native
1个回答
0
投票

最初我会说这是因为在DarkModal上没有像goalModalScreen那样的属性?

或使用三元运算符

this.state.showModalDayPicker

您也可以在状态下设置DarkModal自己的切换。

return (
      <DarkModal visible={this.state.showModalDayPicker}>
      <GoalModalScreen
        visible={this.state.showModalDayPicker}
        done={this.doneDayPicker}
        title='Health benefits'
        height={this.state.goalModalHeight}
      >
      {this.flatList()}
      </GoalModalScreen>
      </DarkModal>
    );
© www.soinside.com 2019 - 2024. All rights reserved.