Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

react-input-range library in React

I am trying to create a Range bar like this

enter image description here

using react-input-range

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

enter image description here

>Solution :

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading