import React, { useCallback, useState } from 'react' import { formatPercentage } from 'Engine/format' import './PercentageField.css' export default function PercentageField({ onChange, value, debounce }) { const [localValue, setLocalValue] = useState(value) const debouncedOnChange = useCallback( debounce ? debounce(debounce, onChange) : onChange, [debounce, onChange] ) return (
{ const value = e.target.value setLocalValue(value) debouncedOnChange(value) }} type="range" value={localValue} name="volume" min="0" step="0.05" max="1" /> {formatPercentage(localValue)}
) }