-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
fix :when rules change trigger validate #727
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough此次更改在 Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
src/Field.tsx (2)
163-167
: 新增的 componentDidUpdate 方法有效解决了问题,但可以进行小优化这个新增的方法很好地解决了当规则变为空数组时验证错误仍然存在的问题。实现逻辑正确,符合 PR 的目标。
不过,我们可以对条件检查进行一个小的优化:
建议将条件检查改为:
- if (!isEqual(prevRules,this.props.rules)) { + if (!isEqual(prevRules, this.props.rules)) {这样可以改善代码的可读性,保持一致的代码风格。
Line range hint
1-1000
: 总体评估:变更有效且影响范围可控此次修改通过添加
componentDidUpdate
方法成功解决了 PR 中描述的问题。具体来说:
- 新增的方法与现有的
Field
类结构集成良好。- 变更没有对代码的其他部分产生负面影响。
- 实现逻辑符合预期,能够在规则发生变化时触发重新验证。
建议:
- 考虑添加单元测试,以确保这个新功能在各种场景下都能正常工作。
- 更新相关文档,说明这个新的行为,特别是对于动态改变规则的用户来说可能很重要。
|
||
public componentDidUpdate({ rules: prevRules }) { | ||
if (!isEqual(prevRules,this.props.rules)) { | ||
this.validateRules(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不对的,validateRules 和 validateTrigger
相关。ant-design/ant-design#51008 里遇到的是手工调用 validateFields
没有更新的问题。而不是 rules
更新后没有自动更新的问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
奥奥我理解错了......我再看看
Fixes: ant-design/ant-design#51008
Summary by CodeRabbit