type of the <input> element to "range" to create a slider.defaultValue passed down from the parent as the uncontrolled input field's initial value.onChange event to fire the onValueChange callback and send the new value to the parent.const Slider = ({
min = 0,
max = 100,
defaultValue,
onValueChange,
...rest
}) => {
return (
<input
type="range"
min={min}
max={max}
defaultValue={defaultValue}
onChange={({ target: { value } }) => onValueChange(value)}
{...rest}
/>
);
};
ReactDOM.render(
<Slider onValueChange={val => console.log(val)} />,
document.getElementById('root')
);Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️