Closed
Description
Environment
Environment:
OS: macOS High Sierra 10.13.4
Node: 8.11.3
Yarn: Not Found
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.4.1 Build version 9F2000
Android Studio: 3.1 AI-173.4819257
Packages: (wanted => installed)
react: 16.3.0-alpha.2 => 16.3.0-alpha.2
react-native: 0.54.2 => 0.54.2
Description
ref
doesn't work. I can't get value from TextInput
Reproducible Demo
No demo!
This real live code is enough for you to understand and reproduce
const first_name = ...
render() {
return (
<View>
<View style={{marginVertical: 10}}>
<TextInput
ref={ ref => this.first_name = ref }
// This doesn't work. You give this as an example in your docs. But this doesn't work
onChangeText={ text => this.first_name.setNativeProps({text}) }
keyboardType={'default'}
placeholder={'Your first name'}
defaultValue={ first_name }
/>
</View>
}
All these things do not work:
this.first_name._inputRef.value // => undefined
this.first_name.value // => undefined
this.first_name._getText() // => returns ONLY defaultValue. Never returns updated value.
this.first_name._inputRef._getText() // => not available