Hi i am using react native\'s webview to display some html, i want that whenever a user clicks a link inside that html, it will open the user\'s browser with that link.
It's possible to do this in a cross-platform way using the built-in Linking class and react-native-webview-bridge.
const generateLink = (text, url) => {
if (url) {
return `${text}`;
} else {
return text;
}
};
const generateHtml = () => `
${generateLink('Link text', 'http://example.com')}
`;
With a WebViewBridge
component rendered like so:
}
source={{ html: generateHtml() }}
onBridgeMessage={url => Linking.openURL(url)}
/>