Slider: Received `false` for a non-boolean attribute `dragging`.

Created on 28 Nov 2018  Â·  3Comments  Â·  Source: react-component/slider

Handle is passing a boolean property to the generated div

screen shot 2018-11-28 at 1 01 33 pm

Most helpful comment

@Bernabe-Felix The problem is a boolean is being passed as the dragging prop, when it is asking for a string. A temporary fix that we found is to wrap Handle in a function that returns it with a modified dragging prop. Something like this can be incorporated into a component:

import Slider, { Handle } from 'rc-slider';

const HandleWrapper = props => {
  const { dragging, ...restProps } = props;

  return (
    <React.Fragment>
      <Handle dragging={dragging.toString()} {...restProps} />
    </React.Fragment>
  );
};

... a lot of code skipped ...

<Slider
  handle={HandleWrapper}
/>

All 3 comments

@Bernabe-Felix The problem is a boolean is being passed as the dragging prop, when it is asking for a string. A temporary fix that we found is to wrap Handle in a function that returns it with a modified dragging prop. Something like this can be incorporated into a component:

import Slider, { Handle } from 'rc-slider';

const HandleWrapper = props => {
  const { dragging, ...restProps } = props;

  return (
    <React.Fragment>
      <Handle dragging={dragging.toString()} {...restProps} />
    </React.Fragment>
  );
};

... a lot of code skipped ...

<Slider
  handle={HandleWrapper}
/>

I'm getting similar error with version 8.7.0 for reverse attribute

image

Take a look at line: const { dragging, ...restProps } = props;.
props should be unwrapped instead of passing them directly like: <Handle dragging={props.dragging.toString()} {...props} />

In the other words, you can't skip const { dragging, ...restProps } = props;.

Was this page helpful?
0 / 5 - 0 ratings