Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [BUG] ModelForm 使用request会显示上一次的数据 #10871

Closed
gexin1 opened this issue Aug 3, 2023 · 1 comment
Closed

🐛 [BUG] ModelForm 使用request会显示上一次的数据 #10871

gexin1 opened this issue Aug 3, 2023 · 1 comment
Labels

Comments

@gexin1
Copy link
Contributor

gexin1 commented Aug 3, 2023

🐛 bug 描述

ModelForm 使用request会显示上一次的数据
查看request获取的值也是最新的
也使用了以下属性

 modalProps={{
          destroyOnClose:true,
  }}

📷 复现步骤 | Recurrence steps

点击第一条数据,modelForm 会显示第一条数据,
关闭modelForm
点击二条数据,modelForm 会显示第一条数据

🏞 期望结果 | Expected results

显示本次数据

💻 复现代码 | Recurrence code

https://codesandbox.io/s/json-lai-sheng-cheng-fen-bu-biao-dan-forked-dtkwrd?file=/App.tsx:752-766

© 版本信息

 "@ant-design/pro-components": "2.6.10",
    "antd": "5.7.0",

🚑 其他信息

@chenshuai2144
Copy link
Collaborator

chenshuai2144 commented Jan 2, 2024

这个问题似乎是由于 ModelForm 组件在每次关闭后没有销毁导致的。你可以尝试在 modalProps 中添加 destroyOnClose 属性并将其设置为true,这样每次关闭 ModelForm 后,下次打开时就会重新创建一个新的实例,而不会保留上一次的数据。你可以在代码中添加以下代码:

modalProps={{
  destroyOnClose: true,
}}

另外,我注意到你的代码中引用的 "@ant-design/pro-components" 版本是"2.6.10",如果还不行可以给 modal 设置一个 key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants