所以我正在创建一个登录表单,其中包含两个字段,分别是用户名和密码;我想将占位符传递给每个字段。但是,无论我尝试什么,都不会显示占位符。
代码
const submit = values => {
console.log('submitting form', values)
};
const renderInput = ({ input: { onChange, ...restInput } }) => {
return <TextInput style = { styles.input } onChangeText = { onChange } { ...restInput }/>
};
const LoginForm = props => { const { handleSubmit } = props;
return (
<View style={styles.container}>
<View>
<Field name="email" placeholder="Email" component={renderInput} />
<Field name="password" placeholder="Password" component={renderInput} />
</View>
<View>
<View style={styles.loginBtnContainer}>
<TouchableOpacity style={styles.button} onPress={handleSubmit(submit)}>
<Text style={{fontSize: 30, color: '#17a2e0'}}>Login</Text>
</TouchableOpacity>
</View>
</View>
</View>
)
}
export default reduxForm({
form: 'test'
})(LoginForm)
如您所见,name
在 renderInput 函数中的 TextInput 中不存在分别带有电子邮件和密码的两个字段。