I am using version 4.2.2 of react-native-render-html. Given the following snippet:
# App.js
import React from 'react';
import HTML from 'react-native-render-html';
export default function App() {
return (
<HTML html='<a href="https://duckduckgo.com/">A Link To Press</a>' />
);
}
I would expect the web-browser to open when I press a link, but instead, nothing happens.
NB: I've updated my answer to include differences between versions
Important note
Because
Linkin.canOpenUrlhas started requiring changing the android Manifest, there has been a bug preventing link press to open a browser in Android. This was fixed in version 6.3.4. So make sure to check your version!6.x
Default behavior is to handle link press events with React Native
LinkingAPI. If you need to customize link press handling, you should userenderersProps.a.onPressprop.5.x & 4.x
In v5, pressing links is handled by
LinkingAPI by default, and the behavior can be overridden byonLinkPressprop. On v4, it is your responsibility to handle links. For that end, useonLinkPressprop andLinkingutility from React Native. Be careful, if you're using Expo, you should importLinkingfromexpo-linking.