slider icon indicating copy to clipboard operation
slider copied to clipboard

defaultValue not working in Slider

Open DylanKeystoke opened this issue 7 years ago • 5 comments

Trying to set the slider to a default position and I followed the guidelines as best i can tell:

                <Slider
                    step={1000}
                    defaultValue={10000}
                    min={0}
                    max={1000000}
                    onChange={props.onSliderChange}
                    value={props.audienceSize}
                    style={{ marginTop: 10 }}
                  />

However, the slider stays in position

DylanKeystoke avatar Jun 27 '18 21:06 DylanKeystoke

Setting a value with the 'value' prop puts the handle at that value. One fix is to update the value prop with every redraw when sliding. That works for me, but I don't know if this is the best solution.

terraswat avatar Aug 03 '18 22:08 terraswat

Have this issue as well, defaultValue doesnt work for me

eambutu avatar Dec 11 '18 23:12 eambutu

In my case defaultValue works for the first render, but changing the defaultValue does not trigger a new render. So the fix here may be as simple as to trigger a re-render when defaultValue changes.

itayganor avatar Dec 25 '18 14:12 itayganor

same problem, defaultValue on zero position.

nazarposhta avatar Sep 05 '19 07:09 nazarposhta

It seems that using the defaultValue prop has the downside that it doesn't trigger a render of the component when that has been changed. I would try swapping out defaultValue for just value; that works for me

Huz-Amar avatar Oct 05 '22 15:10 Huz-Amar