我有这个问题。如您所见,我已经导出(使用redux)组件。我做错什么了?
...
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);我搜索过了,但没成功,你们能帮我吗?
发布于 2018-03-22 05:01:33
问题是,您正在使用某个对象,即未定义的。因此,下面是您需要注意的可能性:
props.email
props.senha您可以在其中一个或两者中得到未定义的信息。你可以直接用console props。这样你就能知道这件事了。
console.log(JSON.stringify(props));您可以添加高度和宽度。
希望它能帮到你!
发布于 2018-03-22 06:16:29
@Rahamin似乎在钱上。试一试
const PrincipalComponent = connect(mapStateToProps, { modificaEmail, modificaSenha })(Principal);
export {
PrincipalComponent as Principal
};然后
import { Principal } from './Principal';https://stackoverflow.com/questions/49420644
复制相似问题