DouyinFE / semi-design

🚀A modern, comprehensive, flexible design system and React UI library. 🎨 Provide more than 3000+ Design Tokens, easy to build your design system. Make Semi Design to Any Design. 🧑🏻‍💻 Design to Code in one click
https://semi.design
Other
8.43k stars 711 forks source link

[BUG] Form 组件在 strict & development 下调用 validate() 没有返回 #2210

Closed nekocode closed 5 months ago

nekocode commented 6 months ago

Is there an existing issue for this?

Which Component

Form

Semi Version

2.57.0

Current Behavior

在 strict & development 下调用 formApi.validate() 没有返回/反应

Expected Behavior

正常展示错误提示

Steps To Reproduce

No response

ReproducibleCode

No response

Environment

- OS: MacOS
- browser: Chrome

Anything else?

No response

nekocode commented 6 months ago

经 debug 发现是在: https://github.com/DouyinFE/semi-design/blob/6033634945dc0d07c54f978881e2f7a1c1fbcdca/packages/semi-ui/form/hoc/withField.tsx#L277 这里 isUnmounted 返回 true 导致的。在 strict & development 下 useEffect 会调用两次,所以需要在 usEffect 里重置标志。具体可以看这个 PR: https://github.com/DouyinFE/semi-design/pull/2211/files