Created
July 12, 2022 16:18
-
-
Save estevam5s/58bba439025b66454efe4dfc248444a1 to your computer and use it in GitHub Desktop.
form.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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