javascript - HandleSubmit 在 Redux 表单和 React Native - 没有值打印出来
问题描述
当我尝试使用 Redux Form 时,我遇到了问题,handleSubmit
控制台中没有打印任何内容。
这是我的代码:
const renderTextInput = field => {
const {
meta: { touched, error },
label,
secureTextEntry,
maxLength,
keyboardType,
placeholder,
input: { onChange, ...restInput }
} = field;
return (
<View>
<InputText
onChangeText={onChange}
maxLength={maxLength}
placeholder={placeholder}
keyboardType={keyboardType}
secureTextEntry={secureTextEntry}
label={label}
{...restInput}
{...onChange}
/>
{touched && error && <Text style={styles.errorText}>{error}</Text>}
</View>
);
};
class SingUp extends Component {
onSubmit = values => {
console.log(values);
};
render() {
const { handleSubmit } = this.props;
return (
<View style={styles.container}>
<View style={styles.logoContainer}>
<Image
style={{ height: 140, width: 140 }}
source={require("../images/logo.png")}
/>
<Text style={styles.logoText}>Complete el formulario</Text>
</View>
<View style={styles.formContainer}>
<Field
placeholder="Nombre y Apellido"
value="asd"
name="name"
component={renderTextInput}
/>
<Field
placeholder="Mail"
keyboardType="email-address"
name="mail"
component={renderTextInput}
/>
<Field
placeholder="Contraseña"
secureTextEntry={true}
name="password"
component={renderTextInput}
/>
<Field
placeholder="Celular"
name="tel"
keyboardType="numeric"
component={renderTextInput}
/>
<Field
placeholder="DNI"
name="dni"
keyboardType="numeric"
component={renderTextInput}
/>
<TouchableOpacity
style={styles.button}
onPress={handleSubmit(this.onSubmit)}
>
<Text style={styles.buttonText}>Crear cuenta</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => Actions.pop()}>
<Text style={styles.textSingUp}> Ya tengo cuenta</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
export default reduxForm({
form: "register",
fields: ["name", "mail", "password", "tel", "dni"]
})(SingUp);
我从堆栈溢出中尝试了几件事,但我找不到这些的解决方案。
如果社区中的任何人可以帮助我,我将不胜感激,Ty。
解决方案
推荐阅读
- powerbi - PowerBI Refresh - 仅附加在文件夹中的最新文件中
- python - 替换字符串中的特殊字符
- python - Tornado websocket 与动态 MongoDB Motor 手表
- python - 如何在python中运行多个fedora命令
- javascript - #jquery 对话框不是函数
- javascript - 如何自定义jQuery图像预览代码
- synology - 淘汰唯一的卷,保存重要的文件
- ios - 使用 StandardCyborg 3D 扫描 API 和保存数据时遇到问题
- python - 在循环之后如何为一些独立的静态任务赋予任务依赖关系。空气流动
- c++ - 如何从输入创建具有大小的位集