How can I convert the material ui range sliders output(newValue) to string

Viewed 31

I have started using the Material UI library recently. I have used Range slider component. I am handling the change using the handleChange function. Which has 2 arguments event and newValue. When I logged out newValue I got an array with 2 number elements.

The issue is I want the newValue as string

So to do that applied toString() method on the newValue but it gave me an error on Changing the silder position that Failed prop type: Invalid prop value supplied to ForwardRef(Slider), expected one of type [number].

This is the default code snippet

    const handleAgeChange = (event, newValue) => {
        setValue({ ...value, ageRange: newValue })
    };

and this is the one in which I used toString() method

    const handleAgeChange = (event, newValue) => {
        setValue({ ...value, ageRange: newValue.toString() })
    };
0 Answers
Related