-
-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supporte #514
Comments
This seems to be the same issue as #375 |
Are you using Expo? In that case you need to upgrade to SDK 39 (which isn't out yet 🙈) Are you developing for iOS? Can you try run |
No I am not. I am developing for iOS, and have ran a number of I ended up going with |
@chinomnsoawazie this is surprising, it should work with regular react-native in the way you show above. Would you mind comparing your setup with https://github.com/ctavan/uuid-example-react-native which also uses react-native 0.63.2 and works flawlessly? Please beware that |
Just tried your suggested configuration this way...
So, that suggestion did not work. I did not expect it to work though because I was wondering what difference it would make placing |
Hmm, does the same error appear when you clone https://github.com/ctavan/uuid-example-react-native and run:
|
I am not exactly sure why you need me to clone your repo for this issue; I have taken a look at your |
The expo-related issue from #375 is clearly understood and reproducible. If you are seeing the same error on a non-expo react native app it must be a different issue, as https://github.com/ctavan/uuid-example-react-native proves that it is well possible to use Please provide a Minimal Reproducible Example, otherwise I simply don't have enough information about your specific setup in order to further debug this. |
Here is the repo for the ongoing demonstration project that this situation happens. Feel free to use it for debugging purposes. Hopefully that helps as all I really wanted to do was raise this issue with hopes of drawing your attention to it. I really wish I had the time resources to invest more on this. Regards. https://github.com/chinomnsoawazie/dogstagram-frontweb-mobile |
Import react-native-get-random-values _before_ importing App (which in turn imports uuid). As documented in https://github.com/uuidjs/uuid#react-native Fixes uuidjs/uuid#514
As mentioned in the documentation and as shown in the working example I've submitted a PR to your sample repo which hopefully fixes the issue https://github.com/chinomnsoawazie/dogstagram-frontweb-mobile/pull/1 (I couldn't properly test it because I couldn't get past the login screen, I was able to produce a uuid on the login screen though using this commit: ctavan/dogstagram-frontweb-mobile@efac2b8). |
I think the most important line in your last comment is " "getRandomValues() not supported" React Native
Cursory reading of that makes one think that will work in the component where |
One reason why importing it directly before This is indeed something I didn't really consider so far. I will update the documentation to be a bit more clear on that. |
Is this something |
I don't see how? The problem here really is that we get the reference to Lines 5 to 25 in ac1b3af
This is where the import order dependency comes from. We could move this statement into the Another idea would be to actually throw on load time. WDYT? |
This solution works on me
|
I have implemented a polyfill for |
Awesome, Thank you |
You are welcome :-) |
I run into the same issue when running
|
@here-nerd : I'm not familiar with LiquidPlayer but it looks like it's a Node.js runtime (variant). As such it shouldn't be using the Maybe check to make sure your packager is bundling for the correct target environment. For example. |
@chinomnsoawazie Your method works if you are importing |
Today i use rollup to build and run into the same issue. Then, i check the |
Just wanted to add that this issue is fixed in jest v29. But I guess your main environment still needs to run in localhost or https |
move uuid to external module to fix uuidjs/uuid#514
If you got this error in ctypo just install this library in your index.js add this line
|
@adnansudozai et al: What version of Your solution is effectively what Be aware that libraries like |
Just got this surprising error after using uuid for so long
Environment
"react-native": "0.63.2"
"react-native-get-random-values": "^1.4.0"
"uuid": "^8.3.0"
What was tried
I get this error when
const id = uuidv4()
runs. I added "react-native-get-random-values" as suggested, but with yarn and imported it this way;import React, {useState} from 'react';
import 'react-native-get-random-values';
import {v4 as uuidv4} from 'uuid';
import RNPickerSelect from 'react-native-picker-select';
I am still getting the same error. Have to figure out other ways to generate a random ID then.
[Clear, concise description of the problem]
How to reproduce
const id = uuidv4()
Expected behavior
Should generate random ids
Runtime
The text was updated successfully, but these errors were encountered: