Search code examples
reactjsrangematerial-uifocusfiltering

Material UI Range Min Max Error: Cannot read property 'focus' of null


I'm new in React and in MaterialUI. I'm trying to make range filter with min and max inputs and range line using MaterialUI and it example with number-format. If I use prop 'value' to Slider, when I try to move thumb, the error throws:

Uncaught TypeError: Cannot read property 'focus' of null.

But not all times. If I use prop 'defaultValue' there's no such error, but in console is another one:

Material-UI: A component is changing the default value state of an uncontrolled Slider after being initialized. To suppress this warning opt to use a controlled Slider.

What should I do to make it work? Code in Sandbox


Solution

  • to get rid of that warning do this:

    setValues({
      ...values,
      [name]: Number(value)
    });
    

    the API says it's expecting a Number but you are providing a string