-
Notifications
You must be signed in to change notification settings - Fork 352
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(Slider): Update state when properties are updated. #1223
fix(Slider): Update state when properties are updated. #1223
Conversation
Invoke onSlide when slider-input changes
978ce67
to
d7f3aa9
Compare
PatternFly-React preview: https://1223-pr-patternfly-react-patternfly.surge.sh |
Pull Request Test Coverage Report for Build 4080
💛 - Coveralls |
@@ -17,12 +17,19 @@ class Slider extends React.Component { | |||
}; | |||
} | |||
|
|||
componentDidUpdate(prevProps) { | |||
if (prevProps.value !== this.props.value) { | |||
this.onSlide(this.props.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.
state be updated here as well
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.
State needs to be updated when properties change.
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.
exactly
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 didn't change here the state as it triggers a warning and the CI was blocked and also the onSlide needs to be invoked and it updates the state as side effect.
So I think on this way, it saves one render.
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.
Ah, I see... the onSlide function updates the state 👍
(it's a bit confusing to have both a this.onSlide and a this.props.onSlide)
Invoke onSlide when slider-input changes
Fixes #1221