@kthksgy/procedure-call-react-native-web-view
v0.0.1
Published
Procedure Call React Native WebView
Downloads
7
Maintainers
Readme
@kthksgy/procedure-call-react-native-web-view
This document is under construction.
Todos
- Add tests
- Write about how to call procedure
Installation
Run command below.
# npm
$ npm install @kthksgy/procedure-call @kthksgy/procedure-call-react-native-web-view
# yarn
$ yarn add @kthksgy/procedure-call @kthksgy/procedure-call-react-native-web-view
WebView guest usage
- Call
startGuestHandler
- This function creates entrypoint to window for communicating with WebView host.
startWebViewGuestHandler();
WebView host usage
- Create reference for WebView and assign
- Generate host listener and set as
onMessage
- Optionally, console outputs inside WebView Guest can be bypassed by installing
bypassConsole
const webViewReference = useRef<WebView>(null);
const listener = useMemo(function () {
return generateWebViewHostListener(function () {
return webViewReference.current;
});
}, []);
return (
<WebView
injectedJavaScript={generateBypassConsoleInstaller() + 'true;'}
onMessage={listener}
ref={webViewReference}
/>
);