Skip to content

Instantly share code, notes, and snippets.

@estevam5s
Created July 12, 2022 16:18
Show Gist options
  • Save estevam5s/58bba439025b66454efe4dfc248444a1 to your computer and use it in GitHub Desktop.
Save estevam5s/58bba439025b66454efe4dfc248444a1 to your computer and use it in GitHub Desktop.
form.js
import React from 'react';
import { View, TextInput, Button } from 'react-native';
import { withFormik } from 'formik';
const Form = (props) => (
<View style={styles.container}>
<TextInput
value={props.values.email}
onChangeText={text => props.setFieldValue('email', text)}
/>
<TextInput
value={props.values.password}
onChangeText={text => props.setFieldValue('password', text)}
/>
<Button
onPress={props.handleSubmit}
title="Login"
/>
</View>
);
export default withFormik({
mapPropsToValues: () => ({ email: '', password: '' }),
handleSubmit: (values) => {
console.log(values);
}
})(Form);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment