Fix login state

This commit is contained in:
Jake Howard 2016-02-01 22:41:36 +00:00
parent 298e551f61
commit c4c306653d
2 changed files with 23 additions and 16 deletions

View file

@ -1,6 +1,4 @@
import React from 'react-native'; import React from 'react-native';
import Immutable from 'immutable';
import GlobalStyles from '../../settings/styles'; import GlobalStyles from '../../settings/styles';
const { const {
@ -47,13 +45,20 @@ const styles = StyleSheet.create({
export default class Login extends React.Component { export default class Login extends React.Component {
constructor() { constructor() {
super(); super();
this.state = Immutable.Map({ this.state = {
password: '',
}); };
this.validate = this.validate.bind(this);
this.updateState = this.updateState.bind(this);
}
updateState(key, value) {
let state = this.state;
state[key] = value;
this.setState(state);
} }
validate() { validate() {
} }
componentWillMount() { componentWillMount() {
@ -69,8 +74,8 @@ export default class Login extends React.Component {
</Text> </Text>
<TextInput <TextInput
style={styles.input} style={styles.input}
onChangeText={(password) => this.state.set('password', password)} onChangeText={(password) => this.updateState('password', password)}
value={this.state.get('password')} value={this.state.password}
onSubmitEditing={this.validate} onSubmitEditing={this.validate}
placeholder="Password" placeholder="Password"
/> />

View file

@ -8,8 +8,10 @@
"test": "npm run lint" "test": "npm run lint"
}, },
"dependencies": { "dependencies": {
"circleci": "=0.3.0",
"immutable": "=3.7.6", "immutable": "=3.7.6",
"react-native": "=0.19.0", "react-native": "=0.19.0",
"react-native-side-menu": "=0.18.0",
"react-native-vector-icons": "=1.0.4", "react-native-vector-icons": "=1.0.4",
"underscore": "=1.8.3" "underscore": "=1.8.3"
}, },