1.7.3 • Published 5 years ago

react-native-bridged-webview v1.7.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

React Native Bridged Webview

The parts you need to create a react-native/webview hybrid mobile app.

npm install react-native-bridged-webview

Description

Every hybrid mobile app contains three essential parts: 1) Native code that creates a WebView 2) A website that lives inside the WebView 3) A bridge that faciliates communication between these 2 components

This package provides a <BridgedWebView /> component and the companion bridge mechanism to faciliate 2-way promisable-communication between a website and react-native. This allows javascript within the website to talk to the react-native code.

Example

// the main react-native entry js file
import React from 'react';
import BridgedWebView from 'react-native-bridged-webview';
import source from './index.html';

const onBridgedWebViewCall = (type, payload) => {
  switch (type) {
    case 'whoami':
      return 'Joe';
    case 'makemewait':
      return new Promise(resolve => setTimeout(resolve, payload));
  }
};

export default () => (
  <BridgedWebView
    color="#000"
    onCall={onBridgedWebViewCall}
    source={source}
  />
);
// js somewhere within the index.html file
import bridge from 'react-native-bridged-webview/bridge';

(async () => {
  const name = await bridge('whoami');
  await bridge('makemewait', 3000);
  document.body.innerText = `Finally! My name is ${name}`;
})();
1.7.3

5 years ago

1.7.2

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago