Formik: handleSubmit is never called in React native app

Created on 13 Jul 2018  路  1Comment  路  Source: formium/formik

Current Behavior

withFormik handleSubmit is never called in React native project

Steps to Reproduce


This is the button that triggers the handleSubmit (a wrapper of TouchableOpacity)

<Button
   style={styles.submit(isSubmitting && !isValidating)}
   text="ANMELDEN"
   disabled={isSubmitting && !isValidating}
   onClick={handleSubmit}
/>

This is my form:

const FormikSignin = withFormik({
  handleSubmit: (values, { setSubmitting }) => {
    alert('should be triggered');
  },
  mapPropsToValues: (props) => ({ email: '[email protected]', password: 'password' }),
  validate,
})(Signin);

export default class SigninScreen extends React.Component {

  static navigationOptions = {
    headerTitle: <TitleHeader title="ANMELDUNG" />,
    headerRight: <View />
  };

  render() {
    return (
      <FormikSignin />
    );
  }
}

Expected behavior

an alert box should appear containing "should be triggered".


  • Formik Version: 1.0.0-beta-10
  • React Version: 16.3.1
  • TypeScript Version:
  • Browser and Version:
  • OS:
  • Node Version: 8.10.0
  • Package Manager and Version: npm 5.6.0

Most helpful comment

I solved the issue, in fact, I was always returning an errors object like this when there are no errors:

{ username: {}, password: {} }

Whereas the errors object should be an empty object:

{}

I suggest to update the documentation, thank you for the wonderful library.

>All comments

I solved the issue, in fact, I was always returning an errors object like this when there are no errors:

{ username: {}, password: {} }

Whereas the errors object should be an empty object:

{}

I suggest to update the documentation, thank you for the wonderful library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jucesr picture Jucesr  路  3Comments

giulioambrogi picture giulioambrogi  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

pmonty picture pmonty  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments