Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native “;如何修复&x2018;手压器’;react native”;中出现错误;_React Native - Fatal编程技术网

React native “;如何修复&x2018;手压器’;react native”;中出现错误;

React native “;如何修复&x2018;手压器’;react native”;中出现错误;,react-native,React Native,下面是我的登录类代码: export default class Login extends Component { constructor(props) { super(props); this.state = { loggedIn: true, } handlePress = () => { this.props.onHomeviewPress(this.state.data); } } render() {

下面是我的登录类代码:

export default class Login extends Component {

constructor(props) {
    super(props);

    this.state = {
        loggedIn: true,
    }

    handlePress = () => {
        this.props.onHomeviewPress(this.state.data);
    }
}
render() {
    return (
        <View style={styles.container}>
            <Text style={{ color: "blue", fontSize: 28, marginLeft: 10 }}> Login</Text>
            <TextInput style={styles.input}
                underlineColorAndroid="transparent"
                placeholder="Email"
                placeholderTextColor="blue"
                autoCapitalize="none"
            />

            <TextInput style={styles.input}
                underlineColorAndroid="transparent"
                placeholder="Password"
                placeholderTextColor="blue"
                autoCapitalize="none"
            />

            <Button
                onPress={() => this.handlePress.bind(this)}
                title="Login"
            />
        </View>
    );
  }
}
导出默认类登录扩展组件{
建造师(道具){
超级(道具);
此.state={
洛格丁:没错,
}
手按=()=>{
this.props.onHomeviewPress(this.state.data);
}
}
render(){
返回(
登录
这个.把手按.绑(这个)}
title=“登录”
/>
);
}
}
手柄压力功能有问题,不工作,出现错误

undefined不是对象(“this2.handlepress.bind”)


请帮我解决这个问题。提前感谢

您的
handlePress
函数已在构造函数中定义

把它移到外面,它就会工作


此外,您不需要绑定函数。只要
onPress={this.handlePress}
就可以了。

谢谢Jaon!这很有效