Skip to content

Instantly share code, notes, and snippets.

@samcorcos
Created February 24, 2017 01:07
Show Gist options
  • Save samcorcos/c0d541639045e2df0b8ed2678d97dc8d to your computer and use it in GitHub Desktop.
Save samcorcos/c0d541639045e2df0b8ed2678d97dc8d to your computer and use it in GitHub Desktop.
React native local control
import React from 'react'
import { View, TextInput, } from 'react-native'
export class Form extends React.PureComponent {
constructor(props) {
super(props)
this.state = {
input1: null,
input2: null,
}
}
handleChange(text, key) {
this.setState({ [key]: text, })
}
render() {
return (
<View>
<TextInput
style={{ paddingLeft: 10, height: 40, borderColor: 'gray', borderWidth: 1, }}
onChangeText={text => this.handleChange(text, 'input1')} />
<TextInput
style={{ paddingLeft: 10, height: 40, borderColor: 'gray', borderWidth: 1, }}
onChangeText={text => this.handleChange(text, 'input2')} />
</View>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment