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

[formlist] formlist设置了初值的话,点击删除item之后再点击add又会把有初值的item渲染回来 #2650

Open
CassenChan opened this issue Dec 7, 2023 · 2 comments
Labels
💭 discussion we are discussing

Comments

@CassenChan
Copy link

tdesign-react 版本

react

重现链接

https://stackblitz.com/edit/react-fbswqt?file=src%2Fdemo.jsx

重现步骤

企业微信截图_54657a4a-3b6b-4f2a-8654-0d3c3a599a4a

期望结果

No response

实际结果

No response

框架版本

"react": "^18.2.0",

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

Copy link
Contributor

github-actions bot commented Dec 7, 2023

👋 @CassenChan,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@HaixingOoO HaixingOoO added the 💭 discussion we are discussing label Dec 8, 2023
@libo1106
Copy link

libo1106 commented Dec 26, 2024

如果自己另外管理状态的话,可以给 FormItem 拓展一个 unMount 属性,实现表单显示与状态管理保持同样的逻辑,表单联动逻辑多的时候,比 react-hook-form 的 unregister 稍微简单点。

{isShowLink && (
  <FormItem
    label="链接"
    unMount={() => {
      setFieldValue(Fields.link, undefined);
    }}
  >
    <div>
      <Input
        placeholder="请输入链接"
        value={fields.link}
        onChange={(value) => {
          setFieldValue(Fields.link, value);
        }}
      />
    </div>
  </FormItem>
)}

这样能避免表单元素销毁后,旧的表单值还残存

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

No branches or pull requests

3 participants