slider
slider copied to clipboard
Issue with slider
So I have a range slider with tooltips. My problem is that I use custom onChange and value.
<Range
className="c-range"
value={valueState}
onChange={value => setValueState(value)}
min={minPossible}
max={maxPossible}
/>
If I just use Slider.Range without tooltips it works fine. But when I do:
const { createSliderWithTooltip } = Slider;
const Range = createSliderWithTooltip(Slider.Range);
And use Range like in the example above, the value only changes by 1 until I let go and click again.
So I have a range slider with tooltips. My problem is that I use custom onChange and value.
<Range className="c-range" value={valueState} onChange={value => setValueState(value)} min={minPossible} max={maxPossible} />
If I just use Slider.Range without tooltips it works fine. But when I do:
const { createSliderWithTooltip } = Slider; const Range = createSliderWithTooltip(Slider.Range);
And use Range like in the example above, the value only changes by 1 until I let go and click again.
This also happen with Slider...
So I have a range slider with tooltips. My problem is that I use custom onChange and value.
<Range className="c-range" value={valueState} onChange={value => setValueState(value)} min={minPossible} max={maxPossible} />
If I just use Slider.Range without tooltips it works fine. But when I do:
const { createSliderWithTooltip } = Slider; const Range = createSliderWithTooltip(Slider.Range);
And use Range like in the example above, the value only changes by 1 until I let go and click again.
Same here
An workaround for this is, instead of update state in onChange, update in onAfterChange and instead of define value attribute, define the defaultValue, like this:
<Range
min={1}
max={500}
step={1}
draggableTrack={true}
onAfterChange={(val1) => {
setRDistance(val1);
}}
defaultValue={rangeDistance} />