-
Notifications
You must be signed in to change notification settings - Fork 106
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
Change the priorities of defaultChecked and checked #221
base: master
Are you sure you want to change the base?
The head ref may contain hidden characters: "feature/\u4FEE\u6539defaultChecked\u7684\u4F18\u5148\u7EA7"
Change the priorities of defaultChecked and checked #221
Conversation
src/index.jsx
Outdated
@@ -21,7 +21,7 @@ class Checkbox extends Component { | |||
constructor(props) { | |||
super(props); | |||
|
|||
const checked = 'checked' in props ? props.checked : props.defaultChecked; | |||
const checked = 'defaultChecked' in props ? props.defaultChecked : 'checked' in props ? props.checked : false; |
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.
Can the double ternary operator be avoided?
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.
It is wrong to read defaultChecked before checked, checked should be top priority.
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.
I need to look at the code again🧎♂️。I will reopen this pr after I fix it。
Test case needed. |
👌 |
There is no need to create another PR, just continue to push your changes. |
when the checked value is undefined or null, input will ignore this property,I changed the code follow this principle. There's another question, ‘// eslint-disable-next-line import/no-extraneous-dependencies’ ,when this code exist,it will commit failed,the termminal reported an error: 'Definition for rule 'import/no-extraneous-dependencies' was not found ',what should I do?🧎♂️ |
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
#35130
💡 Background and solution
📝 Changelog
☑️ Self Check before Merge