This commit is contained in:
u-e 2018-12-22 00:19:39 +03:00
parent ed721942fa
commit 929130ba3a

View File

@ -6,7 +6,6 @@ import { View, TouchableOpacity, Animated } from 'react-native';
// Components // Components
// Styles // Styles
// eslint-disable-next-line
import styles from './toggleSwitchStyles'; import styles from './toggleSwitchStyles';
class ToggleSwitchView extends PureComponent { class ToggleSwitchView extends PureComponent {
@ -24,7 +23,7 @@ class ToggleSwitchView extends PureComponent {
circleWidth: 28, circleWidth: 28,
circleHeight: 28, circleHeight: 28,
translateX: 36, translateX: 36,
isOn: false || props.isOn, isOn: props.isOn || false,
}; };
} }
@ -70,15 +69,12 @@ class ToggleSwitchView extends PureComponent {
_onToggle = () => { _onToggle = () => {
const { onToggle } = this.props; const { onToggle } = this.props;
const { isOn } = this.state; const { isOn } = this.state;
this.setState({ isOn: !isOn });
this.setState( // For debounce
{ setTimeout(() => {
isOn: !isOn, if (onToggle) onToggle(!isOn);
}, }, 300);
() => {
onToggle && onToggle(!isOn);
},
);
}; };
render() { render() {