Last active
December 13, 2017 11:05
-
-
Save kawnayeen/6d845488f88967ab3f190300f238d8d6 to your computer and use it in GitHub Desktop.
Input field component
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
onEmailChange(text) { | |
this.emailAddress = text; | |
} | |
<Input | |
label="Email" | |
placeholder="email@gmail.com" | |
onChangeText={this.onEmailChange.bind(this)} | |
/> |
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 { TextInput, View, Text } from 'react-native'; | |
const Input = ({ label, value, onChangeText, placeholder, secureTextEntry }) => ( | |
<View style={styles.containerStyle}> | |
<Text style={styles.labelStyle}>{label}</Text> | |
<TextInput | |
secureTextEntry={secureTextEntry} | |
placeholder={placeholder} | |
autoCorrect={false} | |
value={value} | |
onChangeText={onChangeText} | |
style={styles.inputStyle} | |
/> | |
</View> | |
); | |
const styles = { | |
inputStyle: { | |
color: '#000', | |
paddingRight: 5, | |
paddingLeft: 5, | |
fontSize: 18, | |
lineHeight: 23, | |
flex: 2 | |
}, | |
labelStyle: { | |
fontSize: 18, | |
paddingLeft: 20, | |
flex: 1 | |
}, | |
containerStyle: { | |
height: 40, | |
flex: 1, | |
flexDirection: 'row', | |
alignItems: 'center' | |
} | |
}; | |
export default Input; |
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
constructor() { | |
super() | |
this.emailAddress = ''; | |
this.password = ''; | |
} |
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
onPasswordChange(text) { | |
this.password = text; | |
} | |
<Input | |
secureTextEntry | |
label="password" | |
placeholder="password" | |
onChangeText={this.onPasswordChange.bind(this)} | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment