不变违规:元素类型无效React-Native

时间:2019-08-21 07:15:08

标签: react-native

当我尝试在代码中制作可重用组件时,它显示了一些错误。

enter image description here

下面是我的代码

Login.js

render() {
  return (
    <View style={login.container}>
      <Image source={imageLogo} style={login.logo} />
      <View style={login.form}>
        <ApptiTextInput
          value={this.state.email}
          onChangeText={this.handleEmailChange}
          placeholder={strings.EMAIL_PLACEHOLDER}
        />
        <ApptiTextInput
          value={this.state.password}
          onChangeText={this.handlePasswordChange}
          placeholder={strings.PASSWORD_PLACEHOLDER}
        />
        <ApptiButton label={strings.LOGIN} handleLoginPress={this.handleLoginPress.bind(this)} />
      </View>
    </View>
  );
}

Apptibutton.js

render() {
    const { label, handleLoginPress } = this.props;
    console.log(label);

    return (
      <View  style={apptiButton.container}>
         <TouchableOptacity onPress={handleLoginPress}>
            <Text style={apptiButton.text} >{label}</Text>
         </TouchableOptacity>
      </View>

    );
}

Here is my code

1 个答案:

答案 0 :(得分:0)

Apptibutton.js中有一个错字,TouchableOpacity而不是TouchableOptacity

render() {
    const { label, handleLoginPress } = this.props;
    console.log(label);

    return (
      <View  style={apptiButton.container}>
         <TouchableOpacity onPress={handleLoginPress}>
            <Text style={apptiButton.text} >{label}</Text>
         </TouchableOpacity>
      </View>

    );
}