ImageBackground:元素类型无效

时间:2018-03-22 04:35:25

标签: reactjs react-native

我有这个问题。如您所见,我已经导出(使用redux)Component。我做错了什么?

Error

...

const Principal = (props) => {
    return (

        <ImageBackground   style={{flex : 1}} source={bg} >
            <View style={styles.topo}>
              <Text style={styles.txtTopo}>
                WhatsApp Clone!
              </Text> 
            </View>

            <View style={styles.centro}>
              <TextInput value={props.email} onChangeText={ (value) => props.modificaEmail(value) } style={{fontSize: 20, height: 45}} placeholder='E-mail'/>
              <TextInput secureTextEntry value={props.senha} onChangeText = { (value) => props.modificaSenha(value) } style={{fontSize: 20, height: 45}} placeholder='Senha'/>

              <TouchableHighlight  onPress={() => Actions.Cadastrar()} activeOpacity={0.3} underlayColor='#F5FCFF'>
                <Text style={{fontSize: 20}}>Ainda não tem cadastro? Cadastre-se </Text>
              </TouchableHighlight>
            </View>

            <View style={styles.bottom}>
              <Button title='Entrar' color='#115E54' onPress={() => false} />
            </View>
        </ImageBackground>
    );

}

...

const mapStateToProps = (state) => (
  {
    email: state.AutenticacaoReducer.email,
    senha: state.AutenticacaoReducer.senha
  }
)

export default connect(mapStateToProps, { modificaEmail, modificaSenha })(Principal);

我用Google搜索了,但没有成功,所以,你们能帮助我吗?

2 个答案:

答案 0 :(得分:0)

问题是告诉您正在使用某些未定义的对象。以下是您需要查看的可能性:

props.email  
props.senha

您可能会在其中一个或两个中都未定义。您可以console props。所以你可以了解它。

console.log(JSON.stringify(props));

您可以添加高度宽度

希望它能帮到你!!!

答案 1 :(得分:0)

@Rahamin似乎在赚钱。尝试

const PrincipalComponent = connect(mapStateToProps, { modificaEmail, modificaSenha })(Principal);

export {
  PrincipalComponent as Principal
};

然后

import { Principal } from './Principal';
相关问题