-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm.js
45 lines (40 loc) · 1.21 KB
/
Form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React, { Component } from 'react';
import {TouchableWithoutFeedback, View, AppRegistry, TextInput } from 'react-native';
var styles = require('./styles');
export default class MyInput extends Component {
constructor(props) {
super(props);
var ctx = this;
this.state = { text: 'Useless Placeholder' };
this.state.text = this.props.text;
this.state.placeholder = this.props.text;
this.clear = function(){
ctx.setState({removeDiv:true,text:""})
ctx.refs.nameInput.focus();
}
this.checkEmpty = function(){
if(ctx.state.text === ""){
ctx.setState({removeDiv:false,text:ctx.state.placeholder})
}
}
}
render() {
return (
<View>
<TouchableWithoutFeedback onPressIn={this.clear}>
<View style={clearDivStyle}></View>
</TouchableWithoutFeedback>
<View style={styles.defaultInputView}>
<TextInput
style={[styles.defaultInput,textStyle]}
onChangeText={(text) => this.setState({text})}
value={this.state.text}
underlineColorAndroid="#e3e3e3"
onBlur={this.checkEmpty}
ref="nameInput"
/>
</View>
</View>
);
}
}