Hi,
Looking at the Expo WebBrowser example at:
import React, { Component } from 'react';
import { Button, Text, View, StyleSheet } from 'react-native';
import { Constants, WebBrowser } from 'expo';
export default class App extends Component {
state = {
result: null,
};
render() {
return (
<View style={styles.container}>
<Button
style={styles.paragraph}
title="Open WebBrowser"
onPress={this._handlePressButtonAsync}
/>
<Text>{this.state.result && JSON.stringify(this.state.result)}</Text>
</View>
);
}
_handlePressButtonAsync = async () => {
let result = await WebBrowser.openBrowserAsync('https://expo.io');
this.setState({ result });
};
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
},
});
How could a best practice example be to have multiple buttons open different urls?
Should I give each button an externalurl property and pass it to the _handlePressButtonAsync function?
I tried to do it that way with openBrowserAsync(this.props.externalurl) and gave the button externalurl="https://www.google.com"
but seems like it’s undefined.
Any tips, thanks!