zillow / react-slider

Accessible, CSS agnostic, slider component for React.
https://zillow.github.io/react-slider
MIT License
891 stars 232 forks source link

Warning: Using UNSAFE_componentWillReceiveProps in strict mode #193

Closed coolsp closed 3 years ago

coolsp commented 4 years ago

Description

Using react-slider generates a react warning in strict mode:

Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://fb.me/react-unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state

Please update the following components: ReactSlider

Issue seems to be located in ReactSlider.js line 388.

  _proto.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(newProps) {
    var value = sanitizeInValue(newProps.value);

    if (!value.length) {
      // eslint-disable-next-line prefer-destructuring
      value = this.state.value;
    } // ensure the array keeps the same size as `value`

    this.tempArray = value.slice();

    for (var i = 0; i < value.length; i += 1) {
      this.state.value[i] = this.trimAlignValue(value[i], newProps);
    }

    if (this.state.value.length > value.length) {
      this.state.value.length = value.length;
    }
  };
AllStackDev1 commented 4 years ago

Having the same issue

dalbitresb12 commented 3 years ago

Hi @stonebk! Is there any progress on this one?

stonebk commented 3 years ago

react-slider@1.1.1