# react-native-htmlview **Repository Path**: FE-shiyun/react-native-htmlview ## Basic Information - **Project Name**: react-native-htmlview - **Description**: A React Native component which renders HTML content as native views - **Primary Language**: JavaScript - **License**: ISC - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-19 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # React Native HTMLView [](https://travis-ci.org/jsdf/react-native-htmlview) A component which takes HTML content and renders it as native views, with customisable style and handling of links, etc. In action (from [ReactNativeHackerNews](https://github.com/jsdf/ReactNativeHackerNews)):  ## Table of contents - [Install](#install) - [Usage](#usage) - [Example](#example) - [Changelog](#changelog) ### Install ``` npm install react-native-htmlview --save ``` ### Usage props: - `value`: a string of HTML content to render - `onLinkPress`: a function which will be called with a url when a link is pressed. Passing this prop will override how links are handled (defaults to calling `Linking.openURL(url)`) - `onLinkLongPress`: a function which will be called with a url when a link is long pressed. The default is `null`. - `stylesheet`: a stylesheet object keyed by tag name, which will override the styles applied to those respective tags. - `renderNode`: a custom function to render HTML nodes however you see fit. If the function returns `undefined` (not `null`), the default renderer will be used for that node. The function takes the following arguments: - `node` the html node as parsed by [htmlparser2](https://github.com/fb55/htmlparser2) - `index` position of the node in parent node's children - `siblings` parent node's children (including current node) - `parent` parent node - `defaultRenderer` the default rendering implementation, so you can use the normal rendering logic for some subtree. `defaultRenderer` takes the following arguments: - `node` the node to render with the default rendering logic - `parent` the parent of node of `node` - `bullet`: text which is rendered before every `li` inside a `ul` - `paragraphBreak`: text which appears after every `p` element - `lineBreak`: text which appears after text elements which create a new line (`br`, headings) - `addLineBreaks`: when explicitly `false`, effectively sets `paragraphBreak` and `lineBreak` to `null` - `NodeComponent`, `nodeComponentProps`, `RootComponent`, `rootComponentProps`, `TextComponent`, `textComponentProps`: see the heading **Customizing things even further** below. ### Example ```js import React from 'react'; import {StyleSheet} from 'react-native'; import HTMLView from 'react-native-htmlview'; class App extends React.Component { render() { const htmlContent = `
`; return (