Skip to content

Instantly share code, notes, and snippets.

@manojsinghnegiwd
Created March 18, 2017 16:03
Show Gist options
  • Save manojsinghnegiwd/19f9b143587c43c919705047462fa396 to your computer and use it in GitHub Desktop.
Save manojsinghnegiwd/19f9b143587c43c919705047462fa396 to your computer and use it in GitHub Desktop.
const {value, height} = this.state;
export default class YourComponent extends Component {
constructor (props) {
super(props);
this.state = {
newValue: '',
height: 40
}
}
updateSize = (height) => {
this.setState({
height
});
}
render () {
const {newValue, height} = this.state;
let newStyle = {
height
}
return (
<TextInput
placeholder="Your Placeholder"
onChangeText={(value) => this.setState({value})}
style={[newStyle]}
editable={true}
multiline={true}
value={value}
onContentSizeChange={(e) => this.updateSize(e.nativeEvent.contentSize.height)}
/>
)
}
}
import {
TextInput
} from 'react-native';
const {value, height} = this.state;
let newStyle = {
height
}
this.state = {
value: '',
height: 40
}
<TextInput
placeholder="Your Placeholder"
onChangeText={(value) => this.setState({value})}
style={[newStyle]}
editable={true}
multiline={true}
value={value}
onContentSizeChange={(e) => this.updateSize(e.nativeEvent.contentSize.height)}
/>
updateSize = (height) => {
this.setState({
height
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment