Created
March 12, 2018 11:31
-
-
Save asmyk/6bf552d4e1c326391664048d20bd8c14 to your computer and use it in GitHub Desktop.
React native form example with recompose
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
class MyForm extends Component { | |
render() { | |
let { formData, onSubmitForm } = this.props; | |
return ( | |
<View> | |
<TextInput value={formData.name} /> | |
<TextInput value={formData.email} /> | |
<Button onPress={onSubmitForm} title="Send" /> | |
</View> | |
) | |
} | |
} | |
let initialState = { | |
name: 'Eric', | |
email: '[email protected]' | |
} | |
let enhance = compose( | |
withState('formData', 'setFormData', initialState), | |
withHandlers({ onSubmitForm: (props) => event => { console.log('form submitted!') } }) | |
) | |
export default enhance(MyForm); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment