react-native-render-html-table-bridge v0.6.1
Table support for react-native-render-html
npm add --save react-native-render-html-table-bridgeyarn add react-native-render-html-table-bridgeFeatures:
- Render HTML tables with a
WebViewcomponent you provide - Supports
<HTML>onLinkPressprop to handle clicks - Automatic height
Known Limitations:
- don't forget you're rendering cells inside a webview, so you won't be able to apply your custom renderers there
- limited support of Expo <33 version ; full support ≥33 versions (see bellow limitation)
autoheightandonLinkPressconfig options only work withWebView≥v5.0.0community edition
Minimal working example
You need 3 conditions to get to a working example:
- If you're not using Expo, install (
npm add --save react-native-webview) and link (react-native link react-native-webview)react-native-webview - inject
alterNodeandignoredTagsprops toHTMLcomponent makeTableRendererand injectrenderersprop toHTMLcomponent
import React, {PureComponent} from 'react';
import {ScrollView} from 'react-native';
import HTML from 'react-native-render-html';
import { IGNORED_TAGS, alterNode, makeTableRenderer } from 'react-native-render-html-table-bridge';
import WebView from 'react-native-webview';
const html = `
<table>
<tr>
<th>Entry Header 1</th>
<th>Entry Header 2</th>
</tr>
<tr>
<td>Entry First Line 1</td>
<td>Entry First Line 2</td>
</tr>
</table>
`;
const config = {
WebViewComponent: WebView
};
const renderers = {
table: makeTableRenderer(config)
};
const htmlConfig = {
alterNode,
renderers,
ignoredTags: IGNORED_TAGS
};
export default class Example extends PureComponent<Props> {
render() {
return (
<ScrollView>
<HTML html={html} {...htmlConfig}/>
</ScrollView>
)
}
}makeTableRenderer config
This config object will be passed to the HTMLTable component as props.
Read through typescript definitions to discover available config options.
WebViewComponent
Required
Your WebView component.
Warning: Features such as autoheight and onLinkPress don't work with the legacy core version or Expo <33 version.
Please use latest community edition instead
autoheight
Optional
Fit height to HTML content.
default: true
Supported WebView: WebView community edition ≥5.0.0 and Expo SDK ≥33.
Warning: This prop causes a tiny flicker, because we have to wait the WebView DOM tree to be rendered before receiving the exact height. We use LayoutAnimation when the height changes to soften the transition, but you must enable the feature on android.
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago