One cannot access the Slider's value on events onDragStop and onDragStart.
Edit: neither does onMouseUp work. Only onChange gets the event value attached.
I did injectTapEventPlugin();.
<Slider onDragStop={this.onTest} ... />
onTest(e, value) {
console.log(e, value, e.target.value)
}
Returns: Event, undefined, undefined.
I think is you event bind wrong.
I wrote a demo for you, and the value is right.
import React from 'react';
import Slider from '../src/Slider';
import injectTapEventPlugin from 'react-tap-event-plugin';
// Needed for onTouchTap
// http://stackoverflow.com/a/34015469/988941
injectTapEventPlugin();
/**
* `SelectField` supports a floating label with the `floatingLabelText` property. This can be fixed in place with the
* `floatingLabelFixed property, and can be customised with the `floatingLabelText` property.
*/
export default class App extends React.Component {
constructor(props) {
super(props);
}
changeSlider(event, value) {
console.log(value);
}
render() {
return (
<Slider
defaultValue={1}
onChange={(event, value) => this.changeSlider(event, value)}
/>
);
}
}
This is onChange in your example. onChange works fine. onDragStop does not.
I have this use-case where the slider's value is changed with a timer (setInterval) but it can be changed by the user if he slides the slider, the problem is that i want to catch the change of the value only if the user slides the slider and this is impossible right now :( because the event we get from onDragStop doesn't have a value attribute.
We plan on migrating the component to the v1-beta branch. I'm closing the issue for #4793.
Most helpful comment
This is
onChangein your example.onChangeworks fine.onDragStopdoes not.