Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.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
Reactjs 不变冲突:元素类型无效-反应本机_Reactjs_React Native - Fatal编程技术网

Reactjs 不变冲突:元素类型无效-反应本机

Reactjs 不变冲突:元素类型无效-反应本机,reactjs,react-native,Reactjs,React Native,Git hub回购协议如下: 当我要在我的Genny运动模拟器上运行react本机应用程序时,此错误显示在红色背景区域 不变冲突:元素类型无效:应为 内置组件或复合组件的类/函数 但我得到了一个目标。您可能忘记了从导出组件 在中定义的文件 这是'src/pages/'文件夹中的Login.js import * as React from 'react'; import { TouchableOpacity , View , StyleSheet , ScrollView ,

Git hub回购协议如下:

当我要在我的Genny运动模拟器上运行react本机应用程序时,此错误显示在红色背景区域

不变冲突:元素类型无效:应为 内置组件或复合组件的类/函数 但我得到了一个目标。您可能忘记了从导出组件 在中定义的文件

这是'src/pages/'文件夹中的Login.js

import * as React from 'react';
import {
  TouchableOpacity ,
  View , 
  StyleSheet , 
  ScrollView , 
  Text , 
  TextInput , 
  Dimensions , 
  Alert 
} from 'react-native';

import { connect } from 'react-redux';
import Logo from '../components/Logo';
import clickLogin from '../redux/actions/loginActions';
import { Icon } from 'react-native-elements';

const { height } = Dimensions.get('window');

class Login extends React.Component {
  constructor(props){
    super(props);
    this.state = {
      username : '' ,
      password : '' ,
      screenHeight: height ,
      pendingLoginReqest : false 
    } 
  }

  onContentSizeChange = (contentWidth, contentHeight) => {
    this.setState({ screenHeight: contentHeight });
  };

  Login = () => {
      // firebase.auth().signInWithEmailAndPassword(this.state.username , this.state.password)
      //   .then(()=>{

      //   }, (error) => {
      //     Alert.alert(error.message);
      //   })
    this.props.clickLogin(this.state);
  };

  render() {
    const scrollEnabled = this.state.screenHeight > height;
    const {navigate} = this.props.navigation;
    return (
      <ScrollView style={{ flex: 1 }}
          scrollEnabled={scrollEnabled}
          onContentSizeChange={this.onContentSizeChange}
      >
      <View style={styles.container}> 
          <Logo />
          <TextInput style={styles.textinput}
            returnKeyType='next'
            underlineColorAndroid='rgba(0,0,0,0)'
            placeholder='Email or Username'
            keyboardType='email-address'
            autoCapitalize='none'
            autoCorrect = {false}
            onChangeText={data => this.setState({ username : data })}
            onSubmitEditing={() => this.passwordInput.focus()}
            placeholderTextColor = '#ffffff'
          />

          <TextInput style={styles.textinput}
            underlineColorAndroid='rgba(0,0,0,0)'
            placeholder='Password'
            secureTextEntry
            returnKeyType='go'
            onChangeText={data => this.setState({ password : data})}
            ref= {(input) => this.passwordInput = input}
            placeholderTextColor = '#ffffff'
          />

          <TouchableOpacity style={styles.buttonLogin}
            onPress={this.Login}>
            <Text style={styles.loginButtonText}>Login</Text>  
          </TouchableOpacity> 

          <View style={styles.socialLoginButtons}>
            <Icon.Button name='facebook' size={15} backgroundColor='#1c313a'> 
              <Text style={{fontFamily:'Arial', fontSize:15, fontSize: 16,
                fontWeight: '500', color: '#ffffff', 
                textAlign: 'center'}}
              >
              Login with Facebook
              </Text>
            </Icon.Button>      
          </View>

          <View style={styles.socialLoginButtons}>
            <Icon.Button name='twitter' size={20} backgroundColor='#1c313a'> 
              <Text style={{fontFamily:'Arial', fontSize:15,fontSize: 16,
                fontWeight: '500',color: '#ffffff',textAlign: 'center'}}>
                Login with Twitter
              </Text>
            </Icon.Button>      
          </View>

          <View style={styles.signuptextcont}>
            <Text style={styles.signuptext}>Don't have an Account?</Text>
            <TouchableOpacity style={styles.signupbtn} onPress= {()=>navigate('Signup')}>
              <Text style={styles.signuptext}>Signup</Text>
            </TouchableOpacity>
          </View>
        </View>
      </ScrollView>
    );
  }
}

// const mapStateToProps = state => {
//   return {

//   }
// }

const mapDispatchToProps = (dispatch) => {
    return {
      clickLogin : (user) => dispatch(clickLogin(user)) 
    }
}

export default connect(null,mapDispatchToProps)(Login);

const styles = StyleSheet.create({
  container:{
      flex: 1,
      alignItems: 'center',
      justifyContent:'flex-start'
  },
  text:{
    marginVertical:15,
    color: 'rgba(255,255,255,0.7)',
    fontSize: 20
  },
  textinput:{
    width: 300,
    backgroundColor : 'rgba(255,255,255,0.3)',
    borderRadius: 25,
    paddingHorizontal: 16,
    color: '#ffffff',
    marginVertical: 10
  },
  signuptext:{
    color: 'rgba(255,255,255,0.6)',
    fontSize: 16
  },
  socialLoginButtons:{
    paddingVertical: 5,
    marginVertical: 10,
    width: 300,
    backgroundColor: '#1c313a'
  },
  signuptextcont:{
    flexGrow: 1,
    alignItems: 'flex-end',
    flexDirection: 'row',
    justifyContent:'center',
    paddingVertical: 16    
  },
  buttonLogin:{
    width: 300,
    backgroundColor: '#1c313a',
    borderRadius: 25,
    paddingVertical: 12,
    marginVertical: 5
  },
  signupbtn:{
    color : '#ffffff',
    fontSize: 16,
    fontWeight: '500',
    paddingHorizontal:10
  }
});
Logo.js如下所示:

import * as React from 'react';
import { Image, View, StyleSheet, Text } from 'react-native';
import { TextInput } from 'react-native-gesture-handler';


export default class Logo extends React.Component {
    render() {
      return (
        <View style={styles.LogoContainer}> 
            <Image style={{width: 50, height: 50}}
              source={require('../img/favicon.png')}/>
            <Text style={styles.LogoText}>Welcome to the App.</Text>
        </View>
      );
    }
}

const styles = StyleSheet.create({

   LogoContainer:{
      alignItems: 'center',
      justifyContent:'center',
      marginTop:50,
      marginVertical:5,
      marginBottom:5
    },
    LogoText:{
      marginVertical:20,
      color: 'rgba(255,255,255,0.7)',
      fontSize: 20
    }

});

从stacktrace中,问题出现在Login.js第82行:

      <View style={styles.socialLoginButtons}>
        <Icon.Button name='facebook' size={15} backgroundColor='#1c313a'> 
          <Text style={{fontFamily:'Arial', fontSize:15, fontSize: 16,
            fontWeight: '500', color: '#ffffff', 
            textAlign: 'center'}}
          >
          Login with Facebook
          </Text>
        </Icon.Button>      
      </View>

这里您使用的是图标。按钮在检查react原生元素后,没有图标。按钮意味着它将未定义并引发该错误

可能重复的请检查您是否在“../components/Logo”中导出徽标correclty@Vencovsky是的,我查过了。。。这是正确的,没有错误here@Peter我咨询过它。。。但是没有solution@AliYarKhan在我使用此文件之前,请将“../components/Logo”文件添加到您的问题中。。。而且效果很好。。。现在它给了这个错误谢谢这就是问题所在。。。它也给了我关于道具的警告,这是怎么回事?警告信息是什么?