Error in react native
amritk opened this issue · 10 comments
Hello, I saw that the last verison of this had react native support, just wondering if it will be added to this version as well.
Trying to run the following code in Expo
import { createId } from '@paralleldrive/cuid2'
console.log(createId())
Throws the following errors
ERROR ReferenceError: Property 'TextEncoder' doesn't exist, js engine: hermes
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
Did the fix in #28 work for you?
I went back to using the old one, but I'll give that a try
Feel free to reopen if this didn't resolve your issue.
Will do, ty
I tried importing it
import { createId } from '@paralleldrive/cuid2'
import * as fastTextEncoding from 'fast-text-encoding'
console.log(createId())
Same error unfortunately
ERROR ReferenceError: Property 'TextEncoder' doesn't exist, js engine: hermes
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
Could be because I'm using the hermes js engine, but this will become the default on the next expo release.
Thanks for the heads up!
hey @ericelliott I got it working by changing the sha3 package to js-sha3 and removing the bufToBigInt
function.
It fails the histogram test, but it seems to be working otherwise. Let me know if you want me to PR
Or better yet, just added a polyfill here
I added instructions to the README. Can you try them out and see if they work?
Sorry I'm still using my fork, but I'll get around to changing it some day