HandleSubmit в Redux Form и React Native - никаких значений распечатать - PullRequest
1 голос
/ 22 марта 2020

У меня проблема с 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);

Я перепробовал несколько вещей из-за переполнения стека, но не смог найти решение для них.

Я был бы очень признателен, если бы кто-нибудь из сообщества смог мне помочь, Тай.

...