Nativebase: Input loses focus when updating state.

Created on 29 Jun 2016  路  11Comments  路  Source: GeekyAnts/NativeBase

I am using React Naive 0.27.2 with nativebase 0.4.7, I am having trouble using the input component.

As you can see, I am trying to update the state on the input on onChangeText, but when I update the state the focus is lost from the input component. Is there another way to use the input component to get the value from it onSubmit?

edit:
Also TextInput is working correctly, if I substitute it for the input component.


`import {Container, Header, Content, Button, Title, List, ListItem, InputGroup, Input, Icon} from 'native-base';
import React, {Component} from 'react';
import {TextInput, View} from 'react-native';

export default class Login extends Component {

constructor() {
super();
this.state = {user: '', pw: undefined};
}

userNameUpdate(event){

  this.props.actions.createUser(this.state.username, '1234')
}


render() {
  const {login} = this.props

    return (
        <Container>

            <Content>

                    <InputGroup>
                           <Input
                             placeholder="USERNAME"
                             value={this.state.user}
                             onChangeText={(username) => this.setState({username})}/>
                           </InputGroup>

                       <InputGroup>
                           <Icon name="ios-unlock" />
                           <Input
                             placeholder="PASSWORD"
                             secureTextEntry={true}
                             value={(this.state && this.state.pw) || ''}
                             onChangeText={(password) => this.setState({pw: password})}/>
                       </InputGroup>


                   <Button style={{margin:5}} onPress={() => this.userNameUpdate()} block> Login </Button>


            </Content>


        </Container>
    );
}

}
`

bug

Most helpful comment

I am still facing this issue. i am using "native-base": "^2.0.13",

All 11 comments

having the same issue

Yes it's a bug. Will be fixed my monday/tuesday.

Fixed in v0.4.8

Thanks!

I am still facing this issue. i am using "native-base": "^2.0.13",

Yes I am also facing the same issue in "native-base": "2.3.3"

@twelvearrays, @k2glyph Guys did you get any solution for the same?

@k2glyph @anil1712 Facing this issue with 2.3.6?

@SupriyaKalghatgi Yes, its happening in 2.3.6 also.
Please check the attached gif

Keyboard gets disappeared

@SupriyaKalghatgi
FYI: I am using this for Form component
https://github.com/nicolaslopezj/simple-react-form

1518

Was this page helpful?
0 / 5 - 0 ratings

Related issues

natashache picture natashache  路  3Comments

Cotel picture Cotel  路  3Comments

Bundas picture Bundas  路  3Comments

sihemhssine picture sihemhssine  路  3Comments

eggybot picture eggybot  路  3Comments