react-simple-range icon indicating copy to clipboard operation
react-simple-range copied to clipboard

option to reset slider or set value?

Open codemonkeynorth opened this issue 2 years ago • 0 comments

Hi,

it seems that the Slider will take a {value} prop but it's not mentioned in your docs. however the following doesn't seem to work anyway?


  const defaultValue = 0
  const [value, setValue] = useState(defaultValue)

  const handleReset = () => {
    setValue(defaultValue)
  }

  // when this fires it should set the slider value back to 0
  // but the slider doesn't update
  useListener(Slider.RESET, handleReset)

  return (
    <ReactSimpleRange 
      min={min}
      max={max}
      defaultValue={defaultValue}
      value={value} // changing this should update slider
      step="1"
      verticalSliderHeight="100%"
      vertical="true"
      id="slider"
    />
  )
}

thanks for any suggestions J

codemonkeynorth avatar Feb 09 '23 11:02 codemonkeynorth