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: do not mutate tempArray when creating handles #121

Merged

Conversation

mmellado
Copy link

@mmellado mmellado commented Nov 22, 2017

created from the fork by @misino, fix#115

Even if component is defined with defaultValue bigger than 0, the handle can be rendered at position left: 0px.
The render method of react-slider component is called twice at the beginning because of handleResize event which calls setState. On first render, it calculates left as 0, second render sets correct left value.
The issue occurs in React version 16, which implements optimized diffing of DOM changes.
Handle components are not rerendered second time, because they are returned as mutated tempArray. It means that the object reference of handle components is not changed between first and second render. And react 16 evaluates it as no change DOM change.

I've tested these changes and they do fix the handle issues in React 16

Even if component is defined with defaultValue bigger than 0, the handle can be rendered at position `left: 0px`.
The render method of react-slider component is called twice at the beginning because of handleResize event which calls setState. On first render, it calculates left as 0, second render sets correct left value.
The issue occurs in React version 16, which implements optimized diffing of DOM changes.
Handle components are not rerendered second time, because they are returned as mutated tempArray. It means that the object reference of handle components is not changed between first and second render. And react 16 evaluates it as no change DOM change.
@mpowaga mpowaga merged commit 439de4f into zillow:master Feb 28, 2018
@mpowaga mpowaga mentioned this pull request Feb 28, 2018
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.

Handle doesn't start at the correct position in React 16
3 participants