npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-webview2

v1.1.1

Published

This is the `WebView` component in React Native both for Android and iOS, support `auto height` & call js between component and html page, very useful & easily!

Downloads

16

Readme

react-native-webview2

reactnative Version NPM Version NPM Downloads GitHub issues GitHub stars GitHub license Twitter

This is the WebView or Web component in React Native both for Android and iOS, support auto height & call js (not support on ios) between component and html document, very useful & easily!

This is a JavaScript-only implementation of WebView in React Native, named react-native-webview2 or WebView or Web.

  1. react-native-webview2 can change the height of WebView dynamically when you set the prop source={uri:xxx}(until now not yet support html) if you not set the prop style={height:xxx}, otherwise the height of WebView is fixed.
  2. react-native-webview2 also can make you call js in html document or reactnative, if you want to call js in html page from react-native, you just invoke this.web.evalJs("js code...here") from react-native. If you want to call react-native code, you just invoke returnEval("rn code...here") from html page, meanwhile set the prop evalReturn={((r) => {eval(r)}).bind(this)}.
  3. react-native-webview2 support all props of WebView in React Native.

WebView demo project: https://github.com/greatbsky/react-native-webview2-demo

WebView Demo

WebView Usage

  1. Run npm install react-native-webview2@latest --save
  2. Code like this:
import Web from 'react-native-webview2';

<Web
  ref={(c) => {this.web = c}}
  evalReturn={((r) => {eval(r)}).bind(this)}
  source={{uri: 'xxx'}}
  style={[styles.web, {minHeight: 300}]}
  ...other props
  />
  1. Full demo code: https://github.com/greatbsky/react-native-webview2-demo/blob/master/WebView2App/app.js

WebView configuration

special props for WebView

  • evalJs: (not support on ios) handle function if you want to call js in html page from react-native. eg: this.web.evalJs('var t = document.title; alert(t)');
  • evalReturn: require if you need call js fun in react-native from html page. evalReturn={((r) => {eval(r)}).bind(this)}.
  • go: handle function if you need open a new uri. eg: this.web.go('http://xxxxxx');

other

  • returnEval: js function in html page if you want to call js in react-native from html page, eg:returnEval('this.setText("from html page...")'), usually you also need set the prop of component evalReturn={((r) => {eval(r)}).bind(this)}

Licensed

MIT License

中文说明请参见

https://github.com/greatbsky/react-native-webview2/wiki