-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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
[Slider] fix Slider.jsx wrong props.value check #1251
Conversation
@@ -78,8 +78,7 @@ let Slider = React.createClass({ | |||
}, | |||
|
|||
getInitialState() { | |||
let value = this.props.value; | |||
if (value === null) value = this.props.defaultValue; | |||
let value = this.props.value || this.props.defaultValue || 0; |
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.
const?
@@ -94,7 +93,7 @@ let Slider = React.createClass({ | |||
}, | |||
|
|||
componentWillReceiveProps(nextProps) { | |||
if (nextProps.value !== null) { | |||
if (!nextProps.value) { |
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.
Does this break if nextProps.value === 0
?
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.
Sure, and it is kind of problematic for the value field.
But then I was wondering, why did you guys have a check for null
? Because to me, if no value is sent in a prop, it will always be undefined
.
Would there be a problem in doing :
nextProps.value !== undefined
everywhere ?
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 don't see a problem with your fix. This was probably a bug that's been in this component from the beginning.
[Slider] fix Slider.jsx wrong props.value check
Thanks @micaste |
No description provided.