Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input loses focus when updating state. #53

Closed
twelvearrays opened this issue Jun 29, 2016 · 11 comments
Closed

Input loses focus when updating state. #53

twelvearrays opened this issue Jun 29, 2016 · 11 comments
Labels

Comments

@twelvearrays
Copy link

twelvearrays commented Jun 29, 2016

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>
    );
}

}
`

@TimBroddin
Copy link
Contributor

having the same issue

@sankhadeeproy007
Copy link
Contributor

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

@himanshu-satija
Copy link
Collaborator

Fixed in v0.4.8

@TimBroddin
Copy link
Contributor

Thanks!

@k2glyph
Copy link

k2glyph commented May 5, 2017

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

@anil1712
Copy link

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

@anil1712
Copy link

anil1712 commented Jan 18, 2018

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

@SupriyaKalghatgi
Copy link
Contributor

@k2glyph @anil1712 Facing this issue with 2.3.6?

@anil1712
Copy link

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

Keyboard gets disappeared

@anil1712
Copy link

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

@SupriyaKalghatgi
Copy link
Contributor

#1518

@GeekyAnts GeekyAnts locked and limited conversation to collaborators Jan 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants