I need to use a switch toggle in my App (library git: dooboolab/react-native-switch-toggle). I'm using typescript in react-native. I get an error when I set the function for the onPress gestureResponderEvent. It says: type void is not assignable to type boolean.
import React, {Component} from 'react';
import SwitchToggle form 'react-native-switch-toggle';
import {View} from 'react-native';
export default class Login extends Component{
state = {
switchOn : false
}
render(){
return (
<View>
<SwitchToggle
switchOn={this.state.switchOn}
onPress = {this.onPress1} //HERE THE ERROR
/>
</View>
)
}
onPress1 = () =>{
this.setState({switchOn:!this.state.switchOn});
}
}
How can I fix it?