Created
March 18, 2017 16:03
-
-
Save manojsinghnegiwd/19f9b143587c43c919705047462fa396 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {value, height} = this.state; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)} | |
/> | |
) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
TextInput | |
} from 'react-native'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {value, height} = this.state; | |
let newStyle = { | |
height | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.state = { | |
value: '', | |
height: 40 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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)} | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
updateSize = (height) => { | |
this.setState({ | |
height | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment