'react-input-range library in React
I am trying to create a Range bar like this
using react-input-range
but when writing this code
import InputRange from 'react-input-range';
import 'react-input-range/lib/css/index.css';
<form action="">
<InputRange
maxValue={100}
minValue={0}
formatLabel={value => `$${value}`}
value={range}
onChange={value => setRange(value)}
onChangeComplete={value => console.log(value)}
/>
</form>
I got this
Solution 1:[1]
Set the initial value of range(state) and you are good to go.
const [range, setRange ]= useState({
min: 5,
max: 10,
});
<form action="">
<InputRange
maxValue={100}
minValue={0}
formatLabel={value => `$${value}`}
value={range}
onChange={value => setRange(value)}
onChangeComplete={value => console.log(value)}
/>
</form>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | maazakn |


