crypto.getRandomValues() not supported

纵然是瞬间 提交于 2020-05-15 09:25:46

问题


I'm getting this error with npm react-native-webview@9.0.1 when I try to generate a QR code with react-native-qrcode-generator

I'm using react-native with an expo managed workflow. And the thing is it works on iOS, and i only get the error on Android

I searched for a solution myself and I tried installing react-native-get-random-values but that also didn't work.

Any thoughts?


回答1:


I just had the same issue on android. Works fine on iOS.

I solved it with:

  1. Uninstall the existing one npm uninstall react-native-webview
  2. Use expo install react-native-webview instead.



回答2:


I made a snack with Expo SDK 37 and the exact versions you mention:

{
  "dependencies": {
    "react-native-webview": "9.0.1",
    "react-native-qrcode-generator": "1.2.1"
  }
}

It works just fine on my Android phone. The issue must be somewhere else in your implementation.

If you've changed versions recently, try to delete your node_modules and install packages again. Double-check my example and let me know if you do something different?




回答3:


Here is what worked for me

  1. Install react-native-get-random-values

    npm install --save react-native-get-random-values
    
  2. Import react-native-get-random-values before webview import (VERY IMPORTANT)

    import 'react-native-get-random-values';
    import {WebView} from 'react-native-webview';
    

For more information, please read this issue.




回答4:


Try to use : npm install --save react-native-webview
It's works for me.



来源:https://stackoverflow.com/questions/61169746/crypto-getrandomvalues-not-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!