mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 21:19:37 +08:00
doc: remove new key way
This commit is contained in:
parent
44319bec11
commit
61aac68028
@ -37,17 +37,7 @@ and so on.
|
||||
#### 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 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.
|
||||
|
||||
> ```jsx
|
||||
> <Modal key={this.state.newKey} visible={this.state.visible} />
|
||||
> ```
|
||||
|
||||
> Another way is to conditionally mount modal.
|
||||
|
||||
> ```jsx
|
||||
> {this.state.visible && <Modal visible={true} />}
|
||||
> ```
|
||||
> If you wish to open it with brand new state everytime, you need to reset state manually.
|
||||
|
||||
### Modal.method()
|
||||
|
||||
|
@ -36,17 +36,7 @@ title: Modal
|
||||
#### 清空旧数据
|
||||
|
||||
> `<Modal />` 组件有标准的 React 生命周期,关闭后状态不会自动清空。
|
||||
> 如果希望每次打开都是新内容,需要自行手动清空旧的状态。或者打开时给 Modal 设置一个[全新的 key](https://github.com/ant-design/ant-design/issues/4165), React 会渲染出一个全新的对话框。
|
||||
|
||||
> ```jsx
|
||||
> <Modal key={this.state.newKey} visible={this.state.visible} />
|
||||
> ```
|
||||
|
||||
> 另一种方式是根据条件加载 Modal。
|
||||
|
||||
> ```jsx
|
||||
> {this.state.visible && <Modal visible={true} />}
|
||||
> ```
|
||||
> 如果希望每次打开都是新内容,需要自行手动清空旧的状态。
|
||||
|
||||
### Modal.method()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user