react-native-html-webview0.0.17 • Public • Published
Display (possibly untrusted) HTML using a UIWebView in React Native.
A couple of similar projects are HTMLText and HTMLView both of which render a subset of HTML as React Native views. This project takes a slightly different approach of using a UIWebView giving a full HTML renderer, but that means it has to rely on an HTML sanitizer to clean up untrusted HTML.
Install using npm with
npm install --save react-native-html-webview
You then need to add the Objective C part to your XCode project. Drag
AIBHTMLWebView.xcodeproj from the
node_modules/react-native-html-webview folder into your XCode
projec. Click on the your project in XCode, goto
Build Phases then
Link Binary With Libraries and add
NOTE: Make sure you don't have the
AIBHTMLWebView project open seperately in XCode otherwise it won't work.
var HTMLWebView = ;var testView = React;
- html : The html content to display as a string
- makeSafe (default: true) : Run the HTML through an HTML
sanitizer (safe-html) before
inserting it to remove script tags and similar unsafe things. Pass
trueto use the default options for safe-html, pass in
falseto turn it off, or pass in an object to set config options for safe-html.
- autoHeight (default: false) : Automatically adjust the height of the webview to fit the contents (also turns off scrolling).
- onLink : Pass in a function to be called when the user clicks a link, the function will be given the href.
Feedback, questions, suggestions and most of all Pull Requests are very welcome. This is an early version and I want to figure out the best way to continue it.
I'm also available for freelance work!