import { Component } from 'react'; import PropTypes from 'prop-types'; import { observer } from 'mobx-react'; import classnames from 'classnames'; import { Field } from 'mobx-react-form'; // Should this file be converted into the coding style similar to './toggle/index.tsx'? class Slider extends Component { static propTypes = { field: PropTypes.instanceOf(Field).isRequired, className: PropTypes.string, showLabel: PropTypes.bool, disabled: PropTypes.bool, }; static defaultProps = { className: '', showLabel: true, disabled: false, }; onChange(e) { const { field } = this.props; field.onChange(e); } render() { const { field, className, showLabel, disabled } = this.props; if (field.value === '' && field.default !== '') { field.value = field.default; } return (
(!disabled ? this.onChange(e) : null)} />
{field.error &&
{field.error}
} {field.label && showLabel && ( )}
); } } export default observer(Slider);