tajo / react-range

🎚️Range input with a slider. Accessible. Bring your own styles and markup.
https://react-range.pages.dev
MIT License
859 stars 97 forks source link

Warning emitted by isStepDivisible due to floating point value mismatch #110

Open forestlovewood opened 3 years ago

forestlovewood commented 3 years ago

I just noticed that if you try and create a Range control which has the following props <Range step={0.1} min={0.1} max={50} ... /> it will emit a The difference of max and min must be divisible by step warning.

This appears to be because (50 - 0.1) / 0.1 equals 498.99999999999994 in JavaScript, but the expression parseInt(res.toString(), 10) actually just returns 498. Most calculators would return 499 for both.

Thank you!

tajo commented 3 years ago

Ah, maybe we should just remove that warning,

AbeCole commented 3 years ago

+1 remove it

dgershun commented 3 years ago

@tajo I fixed this problem in PR above.