Last active
December 14, 2023 15:50
-
-
Save sbalay/39fc70f73239931db2bce4781c653e55 to your computer and use it in GitHub Desktop.
React Native form, meant to be used with redux-form HOC
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 { reduxForm, Field } from 'redux-form'; | |
import { ScrollView, Text, TouchableOpacity } from 'react-native'; | |
import MyTextInput from './MyTextInput' | |
function MyForm(props) { | |
const formStates = ['asyncValidating', 'dirty', 'pristine', 'valid', 'invalid', 'submitting', | |
'submitSucceeded', 'submitFailed']; | |
return ( | |
<ScrollView keyboardShouldPersistTaps={'handled'}> | |
<Text>Email</Text> | |
<Field | |
name={'email'} | |
component={MyTextInput} | |
/> | |
<Text>The form is:</Text> | |
{ | |
formStates.filter((state) => props[state]).map((state) => { | |
return <Text key={state}> - { state }</Text> | |
}) | |
} | |
<TouchableOpacity onPress={props.handleSubmit}> | |
<Text>Submit!</Text> | |
</TouchableOpacity> | |
</ScrollView> | |
); | |
} | |
export default reduxForm({ form: 'signIn' })(MyForm); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment