1.0.2 • Published 7 years ago

react-native-textinput-autoheight v1.0.2

Weekly downloads
2
License
ISC
Repository
-
Last release
7 years ago

React Native Auto-height

Install:

$ npm i react-native-textinput-autoheight --save

Exampe:

import AutoheightTextInput from 'react-native-textinput-autoheight';

<AutoheightTextInput
    value={this.state.text}
    onChangeText={ this._onChangeText.bind(this) }
/>

_onChangeText(text){
    this.setState({ text });
}

You can use all PropTypes of TextInput.

Newline hook

import AutoheightTextInput from 'react-native-textinput-autoheight';

<AutoheightTextInput
    value={this.state.text}
    onChangeText={ this._onChangeText.bind(this) }
    onSubmitEditing={ this._onSubmitEditing.bind(this) }
    blurOnSubmit={ false }
/<

_onSubmitEditing(){
    if (!this.state.text.endsWith("\n")) {
        let text = this.state.text;
        text = text + "\n";
        this.setState({ text });
    }
}

_onChangeText(text){
    this.setState({ text });
}