withFormik handleSubmit is never called in React native project
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 />
);
}
}
an alert box should appear containing "should be triggered".
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.
Most helpful comment
I solved the issue, in fact, I was always returning an errors object like this when there are no errors:
Whereas the errors object should be an empty object:
I suggest to update the documentation, thank you for the wonderful library.