react-native-multi-slider icon indicating copy to clipboard operation
react-native-multi-slider copied to clipboard

Setting the same number does not update the component

Open darkbasic opened this issue 5 years ago • 1 comments

If you have validation rules in place it may happen that you set the same value as the previous one, but since the UI does not reflect it the component needs to be updated. Unfortunately that doesn't happen and it skips the update.

<MultiSlider
  values={[requiredLevel[0], requiredLevel[1]]}
  sliderLength={viewWidth * 0.9}
  onValuesChangeFinish={([min, max]) => {
    let allowedMin = min < userLevel ? min : userLevel;
    let allowedMax = max > userLevel ? max : userLevel;
    if (allowedMax - allowedMin < 2.5) {
      allowedMax = allowedMin + 2.5 < 10 ? allowedMin + 2.5 : 10;
      allowedMin = allowedMax - 2.5;
    }
    setRequiredLevel([allowedMin, allowedMax]);
  }}
  min={0}
  max={10}
  step={0.1}
  snapped
  enableLabel
/>

darkbasic avatar Mar 26 '20 22:03 darkbasic

You can force this by setting a key={random} a regular react feature. That will nuke the component.

ptomasroos avatar Mar 27 '20 05:03 ptomasroos