# react-native-promisable-webview

> A ReactNative WebView with a Promise-adapter.

Latest version **1.0.2** (published 2017-04-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-promisable-webview
pnpm add react-native-promisable-webview
yarn add react-native-promisable-webview
bun add react-native-promisable-webview
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-04-23 |
| First published | 2017-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | benzaita |
| Keywords | react native, webview, promise, adapter, bridge, wkwebview |

## Links

- npm: https://www.npmjs.com/package/react-native-promisable-webview
- Repository: https://github.com/klarna/promisable-webview
- Issues: https://github.com/klarna/promisable-webview/issues
- npm.io page: https://npm.io/package/react-native-promisable-webview

## Dependencies (1)

- [react-native-wkwebview-reborn](https://npm.io/package/react-native-wkwebview-reborn.md) ^1.2.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-04-23
- 1.0.1 — 2017-04-23
- 1.0.0 — 2017-04-23

## README

# PromisableWebView

A ReactNative WebView with a Promise-adapter.

This component is based on WKWebView which provides a bridge between
ReactNative context and the WebView context. That adapter allows you to
`evaluateJavaScript()` code inside the WebView, and `postMessage()` back to
ReactNative. Note that `evaluateJavaScript()` does not return any value, so in
order to synchronize the ReactNative side needs to wait for some message to
return from the WebView.

This component wraps the WKWebView bridge and allows you to evaluate JS code
within the WebView and get a Promise back:

```js
this.webview.evaluateJavaScriptWithPromise('Promise.resolve()')
  .then(() => console.log('resolved!'))
```

## Handling Page Loads

The WebView might unload the page while a Promise is in "pending" state -
either because the JavaScript code that `evaluateJavaScriptWithPromise()`
evaluates navigates away from the page, or because the web page decides to
reload or navigate away for some other reason.

In such cases the `PromisableWebView` rejects any pending promises with
`"WEBVIEW_RELOADED"` as the reason.

---
_Source: https://npm.io/package/react-native-promisable-webview · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
