不变 violaion.objects 作为反应原生中的反应子问题无效 [英] invariant violaion.objects are not valid as react child issue in react-native
问题描述
当我尝试将 redux 表单包装到 react-native 元素中时,它显示以下错误.
When I am trying to wrap redux form into the react-native elements it shows following error.
这是我的代码
import React,{ Component } from 'react';
import { Field,reduxForm } from 'redux-form';
import { Text,Input } from 'react-native-elements';
import { View,Button } from 'react-native';
const renderField=({label,keyboardType,name}) => {
return(
<View style={{flexDirection:'row',height:50,alignItems:'center' }}>
<Text>
{label}
</Text>
<Input />
</View>
)
}
const RegisterForm=props => {
const {handleSubmit}=props;
return(
<View style={{flex:1,flexDirection:'column',margin:40,justifyContent:'flex-start'}}>
<Field label="Username" component={renderField} name="username" />
<Button title='SUBMIT' onPress={handleSubmit} />
</View>
)
}
const Register=reduxForm({
form:'register',
})(RegisterForm);
export default Register;
当在 react-native 元素中使用 FormInput 时,它可以工作,然后我将其更改为 react-native 元素 1.0.0beta4 并将 formInput 替换为 Input 组件.之后它显示上面的错误.我的调试器窗口也显示一个错误
When used FormInput in react-native elements it works then I am changed it into react-native elements 1.0.0beta4 and replace the formInput with Input component. After that it shows above error.My debugger window also shows an error
调试器窗口
推荐答案
该错误是由于您升级到 react-native-elements beta
导致的,其中包括诸如 按钮组件道具:
The error is due to your upgrade to react-native-elements beta
which include breaking changes like the button component props :
实际错误位于 welcomePage.js
文件中(如您在调试器中所见),您需要将传递给按钮图标道具的对象更改为反应组件(请参阅按钮上面链接中的文档).
The actual error is located in welcomePage.js
file (as you can see in debugger), you need to change the object you pass to the button icon prop to a react component (see the button doc in the link above).
这篇关于不变 violaion.objects 作为反应原生中的反应子问题无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!