-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
chore: clear any #684
chore: clear any #684
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #684 +/- ##
=======================================
Coverage 99.43% 99.43%
=======================================
Files 18 18
Lines 1247 1247
Branches 308 304 -4
=======================================
Hits 1240 1240
Misses 7 7 ☔ View full report in Codecov by Sentry. |
src/Field.tsx
Outdated
@@ -562,11 +557,11 @@ class Field extends React.Component<InternalFieldProps, FieldState> implements F | |||
public getControlled = (childProps: ChildProps = {}) => { | |||
const { | |||
name, | |||
trigger, | |||
trigger = 'onChange', |
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.
这不等价吧,class component 的默认值只有 defaultProps 这个统一入口,去掉之后每次从 this.props 取都需要给默认值
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.
是每次都要给默认值,但是我检查了一遍,只有这一个地方用到了 this.props.trigger
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.
不利于维护
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.
我去年把 antd 所有的 defaultProps 都改成默认值了,就差这里了
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.
antd 都是 FC,不用 defaultProps 的
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.
https://react.dev/reference/react/Component#static-defaultprops
没说废弃吧,和 Component 一起放在 legacy api 里
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.
啊,legacy api 不就可以慢慢干掉了么😕
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.
这样理解:
- defaultProps 在 class component 下没有说明废弃,也没有更好的替代方案
- 整个 Component API 是 legacy,要干掉是一起干掉
放在一起就是说明 Component API 是这么用的
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.
那我上面那个 hook 可以统一入口
Component 用不了 hook 哦
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.
好,我改回去了
defaultProps 已废弃: