@material-ui/core#SliderTypeMap TypeScript Examples
The following examples show how to use
@material-ui/core#SliderTypeMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Input.tsx From Teyvat.moe with GNU General Public License v3.0 | 6 votes |
InputSlider: FunctionComponent<InputSliderProps> = ({
value,
onChange,
...others
}) => {
// Maintains the current state of the slider.
// If the slider has gone a period without changing,
// onChange will be called to propage the change to the local storage.
const [currentValue, setCurrentValue] = useDebouncedState<number>(value, onChange);
const setInternalValue: SliderTypeMap['props']['onChange'] = (
_event,
newValue: number | number[]
) => {
if (_.isArray(newValue)) {
const newInnerValue = newValue[0];
if (newInnerValue != null) setCurrentValue(newInnerValue);
} else {
setCurrentValue(newValue);
}
};
return <MaterialSlider value={currentValue} onChange={setInternalValue} {...others} />;
}