📜  从 WebView 获取 LocalStorage 反应原生 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:27.798000             🧑  作者: Mango

代码示例1
import { WebView } from 'react-native-webview';

const INJECTED_JAVASCRIPT = `(function() {
  const tokenLocalStorage = window.localStorage.getItem('token');
  window.ReactNativeWebView.postMessage(tokenLocalStorage);
})();`;

export default function App() {
  const onMessage = (payload) => {
    console.log('payload', payload);
  };

  return (
    
      
      
    
  );
}