I do not get an error when I delete the component menu I created specially from where I put it, but I get an error when my component is there. Thank you for your comments already.
import Menu from './Navigator'
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { faBars } from '@fortawesome/free-solid-svg-icons';
export default class HeaderLeft extends Component {
constructor(props){
super(props);
this.state={check:false}
}
render() {
return (<SafeAreaView><View onStartShouldSetResponderCapture={() => { this.setState({ check: !this.state.check }) }} style={styles.align}>
<FontAwesomeIcon icon={faBars} size={16} color={"#2D6A4F"} /><Menu check={this.state.check}></Menu></View></SafeAreaView>)
}
}
const styles = StyleSheet.create({
align: {
height: 60, display: 'flex', justifyContent: 'center', padding: 20
},
});```
Have a try by making the changes as the below code in your code.:
add below in the constructor:
this.handleResponderCapture = this.handleResponderCapture.bind(this)
Add below method:
handleResponderCapture = () => {
this.setState({
check: !this.state.check
})
}
Make changes as below in View
<View
onStartShouldSetResponderCapture={this.handleResponderCapture}
style={styles.align}
>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.