Add doc about clearing Modal old state

This commit is contained in:
afc163 2017-01-16 14:30:07 +08:00
parent b7c5fb40ae
commit 75abadac84
2 changed files with 18 additions and 0 deletions

View File

@ -33,6 +33,15 @@ and so on.
| wrapClassName | The class name of the container of the modal dialog | String | - |
| afterClose | Specify a function that will be called when modal is closed completely. | function | - |
#### Destroy on close
> The state of Modal will be preserved at it's component lifecircle.
> If you wish to open it with brand new state everytime, you need to reset state manually. Or simply [give a new random key](https://github.com/ant-design/ant-design/issues/4165) to Modal when visible is changed to `true`, React will treat it as a new component.
> ```
> <Modal key={this.state.newRandomKey} visible={this.state.visible} />
> ```
### Modal.xxx()
There are five ways to display the information based on the content's nature:

View File

@ -32,6 +32,15 @@ title: Modal
| wrapClassName | 对话框外层容器的类名 | String | - |
| afterClose | Modal 完全关闭后的回调 | function | 无 |
#### 清空旧数据
> `<Modal />` 组件有标准的 React 生命周期,关闭后状态不会自动清空。
> 如果希望每次打开都是新内容,需要自行手动清空旧的状态。或者打开时给 Modal 设置一个[全新的 key](https://github.com/ant-design/ant-design/issues/4165) React 会渲染出一个全新的对话框。
> ```
> <Modal key={this.state.newRandomKey} visible={this.state.visible} />
> ```
### Modal.xxx()
包括: