Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Using UNSAFE_componentWillReceiveProps in strict mode #193

Closed
coolsp opened this issue Aug 1, 2020 · 3 comments · Fixed by #196
Closed

Warning: Using UNSAFE_componentWillReceiveProps in strict mode #193

coolsp opened this issue Aug 1, 2020 · 3 comments · Fixed by #196

Comments

@coolsp
Copy link

coolsp commented Aug 1, 2020

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
Copy link

Having the same issue

@dalbitresb12
Copy link

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

stonebk pushed a commit that referenced this issue Nov 3, 2020
@stonebk stonebk closed this as completed in 5fff681 Nov 3, 2020
@stonebk
Copy link
Contributor

stonebk commented Nov 3, 2020

react-slider@1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants