Skip to content

Instantly share code, notes, and snippets.

@trungpv1601
Last active March 15, 2017 05:00
Show Gist options
  • Save trungpv1601/bb7e1413f8db03a01c2b6f4943f27468 to your computer and use it in GitHub Desktop.
Save trungpv1601/bb7e1413f8db03a01c2b6f4943f27468 to your computer and use it in GitHub Desktop.
Dismiss keyboard on React Native: Tắt keyboard khi chạm ra ngoài TextInput

Dismiss keyboard on React Native: Tắt keyboard khi chạm ra ngoài TextInput

import React, { Component } from 'react';
import { TouchableWithoutFeedback, View, TextInput } from 'react-native';
import dismissKeyboard from 'react-native/Libraries/Utilities/dismissKeyboard';

export default class LoginForm extends Component {

  constructor(props) {
      super(props);
      this.state = { text: 'Useless Placeholder' };
  }

  render () {
    	return (
   		<TouchableWithoutFeedback style= { { flex:1}} onPress={dismissKeyboard}>
  			<View style= { { flex:1}}>
				<TextInput
                    			multiline={true}
                        		style= { { height: 100, borderColor: 'gray', borderWidth: 1, marginTop: 100}}
                        		value={this.state.text}
                      		/>
                	</View>
  		</TouchableWithoutFeedback>
   		);
    }
}

trungpv1601 15-03-2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment