Is it possible to open links in a new tab? Etc, a pdf?
I haven’t tried it, but I think this is what you’re looking for:
https://github.com/necolas/react-native-web/issues/162#issuecomment-231513809
I went ahead and modified the Anchor component to the following: I didn’t have luck with External Linking Solution.
import * as React from "react";
import { Linking } from "expo";
import { Text } from "react-native";
export default class Anchor extends React.Component {
_handlePress = () => {
// WebBrowser.openBrowserAsync(this.props.href)
Linking.canOpenURL(this.props.href, this.props.target)
.then(supported => {
if (!supported) {
console.log("Can't handle url: " + this.props.href, this.props.target);
} else {
if (window) {
return window.open(this.props.href, this.props.target);
} else {
return Linking.openURL(this.props.href, this.props.target);
}
}
})
.catch(err => console.error("An error occurred", err));
this.props.onPress && this.props.onPress();
};
render() {
return (
<Text {...this.props} onPress={this._handlePress}>
{this.props.children}
</Text>
);
}
}
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.