jd-opensource / jd-opensource/taro-ui

AtModal的isOpened值在componentDidShow中setState后没有更新视图

Open
#1,173 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.7k
Forks
740
PR merge metrics
No merged PRs in 30d

Description

**问题描述**

AtModal的isOpened值,在componentDidShow()中setState后,在回调函数中打印出的值已经发生改变,但是没有更新视图。
但是在componentWillMount()中进行上述操作,视图会更新。
其他生命周期,未做尝试。

**复现步骤**

```
class Index extends Component<{}, {}> {

state = {
isOpened: false
}

componentDidShow() {
this.setState({ isOpened: true }) // 并没有弹出Modal
}

render () {
return (


提示
test

取消
确定



)
}

}
```

**期望行为**
在 componentDidShow()中setState为true的时候可以弹出Modal

**系统信息**

```
Taro CLI 1.3.38 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.5.0 - E:\Node\node.EXE
Yarn: 1.12.1 - C:\Users\hemiaoqing\AppData\Roaming\npm\yarn.CMD
npm: 6.1.0 - E:\Node\npm.CMD
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.