react-native-webview-autoheight

1.0.6 • Public • Published

React Native WebView Autoheight

React Native WebView which sets it's height automatically with minimal efforts.

You can also add custom CSS style or javascript to your webview using below example.

Downloads

Installation

npm install --save react-native-webview-autoheight

Usage

import MyWebView from 'react-native-webview-autoheight';
const customStyle = "<style>* {max-width: 100%;} body {font-family: sans-serif;} h1 {color: red;}</style>";
const htmlContent = "<h1>This is title</h1><p>Throw your entire HTML here</p>";

<MyWebView
    source={{html: customStyle + htmlContent}}
    startInLoadingState={true}
/>
<MyWebView
    source={{uri: 'http://example.com/helloworld.html'}}
    startInLoadingState={true}
/>

Props

How it works

It is a very simple wrapper around the built-in React Native Webview, which updates the height of the webview based on a state change using onNavigationStateChange.

Feel free to add issues or feature requests

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i react-native-webview-autoheight

      Weekly Downloads

      493

      Version

      1.0.6

      License

      ISC

      Unpacked Size

      4.14 kB

      Total Files

      3

      Last publish

      Collaborators

      • elton