Skip to content
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

Merged
merged 2 commits into from
Jan 25, 2019

Conversation

lucasponce
Copy link
Contributor

Invoke onSlide when slider-input changes

Fixes #1221

@lucasponce lucasponce changed the title Update state when properties are updated. fix(Slider): Update state when properties are updated. Jan 21, 2019
Invoke onSlide when slider-input changes
@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://1223-pr-patternfly-react-patternfly.surge.sh

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4080

  • 3 of 4 (75.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 80.368%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/patternfly-3/patternfly-react/src/components/Slider/Slider.js 3 4 75.0%
Totals Coverage Status
Change from base Build 4074: -0.01%
Covered Lines: 4552
Relevant Lines: 5329

💛 - Coveralls

@@ -17,12 +17,19 @@ class Slider extends React.Component {
};
}

componentDidUpdate(prevProps) {
if (prevProps.value !== this.props.value) {
this.onSlide(this.props.value);
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

Copy link
Contributor Author

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.

Copy link
Member

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)

@jeff-phillips-18 jeff-phillips-18 merged commit 033a38b into patternfly:master Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants