Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 77x 75x 75x 2x 2x 2x 1x 2x 74x 70x 70x 4x 4x | import { useEffect, useState } from "react"; export function getReactNativeWebView(): typeof window.ReactNativeWebView { Iif (window && window.ReactNativeWebView) { return window.ReactNativeWebView; } } export function isNativeEmbed(): boolean { return !!getReactNativeWebView(); } export function getNativeData() { const webview = getReactNativeWebView(); Iif (webview && webview.injectedObjectJson()) { return JSON.parse(webview.injectedObjectJson()); } } export function useIsNativeEmbed(): boolean { const [isNative, setIsNative] = useState(false); useEffect(() => { setIsNative(isNativeEmbed()); }, []); return isNative; } type MessageType = "sendState" | "clearState"; export function sendToNative(type: MessageType, data: any) { if (!isNativeEmbed()) return; getReactNativeWebView()!.postMessage( JSON.stringify({ type: type, data: data }) ); } export function sendState<T>(key: string, value: T) { sendToNative("sendState", { key: key, value: value }); } export function clearState(key: string) { sendToNative("clearState", { key: key }); } |