【问题标题】:Invariant Violation: Element type is invalid React-NativeInvariant Violation:元素类型无效 React-Native
【发布时间】:2019-08-21 07:15:08
【问题描述】:

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

下面是我的代码

登录.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

【问题讨论】:

  • 能否请您发送整个代码
  • 我在上面添加了我的代码作为驱动链接

标签: react-native


【解决方案1】:

Apptibutton.jsTouchableOpacity 中有一个拼写错误,而不是 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>

    );
}

【讨论】:

    猜你喜欢
    • 2017-09-16
    • 2018-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2020-05-10
    • 1970-01-01
    • 2019-12-05
    相关资源
    最近更新 更多