Reputation: 13
<View style={styles.container}>
<TextInput style={{height: 40, borderColor: 'gray', borderWidth: 1}}
onChangeText={(text) => this.setState({text})}
value={this.state.text}/>
<TouchableHighlight underlayColor='white' onPress={onPressButton}>
<Image style={{width: 50, height: 50}}
source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}}
/>
</TouchableHighlight>
</View>
I want to get the View, like in html use the 'getElementById()', but in React native, How do I?
Upvotes: 0
Views: 67
Reputation: 4856
Define a ref
:
<View ref={(ref) => {this._myView = ref}} />
Then in your code you can access the View
like this:
this._myView // Do whatever you need here
Docs here https://facebook.github.io/react/docs/refs-and-the-dom.html#the-ref-callback-attribute
Upvotes: 1