Version
"web3": "^1.2.1"
"react-native": "0.59.10"
From set-up tutorial and https://github.com/ethereum/web3.js/issues/1022, I was able to install web3 in react-native, however I got this error:
Error
Possible Unhandled Promise Rejection (id: 1):
TypeError: Cannot read property 'getReader' of undefined
TypeError: Cannot read property 'getReader' of undefined
at new exports.IncomingMessage (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:222317:34)
at module.exports.ClientRequest._connect (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:222201:22)
at blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:222115:14
at tryCallOne (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:45372:14)
at blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:45473:17
at blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46351:21
at _callTimer (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46240:9)
at _callImmediatesPass (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46276:9)
at Object.callImmediates (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46495:14)
at MessageQueue.__callImmediates (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:16572:16)`
The error occurs when I doing promise method like web3.eth.getTransactionCount or web3.eth.getBlock('latest').
I tried console.log(web3.version), no problem at all
I found out using web3#1.0.0-beta.34 is more stable for react-native, so the question mentioned problem does not appear anymore.
Related
I'm trying to develop an app as my hobby project using React Native + realm DB.
I just want to connect to pre-filled realm DB (sitting inside app-bundle) and do some CRUD ops using view controls.
I've followed the steps in the react-native realm docs, however, I'm facing a strange issue while executing following code.
export async function checkDBFn(): Promise<boolean> {
let bundlePath = RNFS.MainBundlePath + '/OlamDB.realm';
const exists = await RNFS.exists(bundlePath);
if (exists) {
try {
Realm.open({
path: bundlePath,
schema: [DBSchema],
schemaVersion: 5,
});
} catch (e) {
if (e instanceof Error) {
let error = e as Error;
console.log(exists, error.message, e.name, e.stack);
// prints true, undefined is not a function, TypeError, and error stack
}
return exists
}
Getting this error stack:
TypeError: undefined is not a function
at ?anon_0_ (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:174245:21)
at next (native)
at asyncGeneratorStep (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:21697:26)
at _next (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:21716:29)
at tryCallOne (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:53:16)
at anonymous (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:139:27)
at apply (native)
at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:27425:26)
at _callTimer (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:27340:17)
at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:27373:17)
at callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:27537:44)
at __callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:2485:46)
at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:2285:45)
at __guard (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:2465:15)
at flushedQueue (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:2284:21)
at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.MyApp:2278:33)
Initially I thought it as a ployfill issue and I've tried to solve this issue by adding core-js polyfill and importing symbol and iterator, but no luck(actually I got another error, not yet solved :) ).
import 'core-js/stable/symbol';
import 'core-js/stable/symbol/iterator';
Without realm.open() code, application code works fine. I've tested the pre-filled DB with NodeJS code and its working perfectly.
Environment:
Deps:
"core-js": "^3.26.0",
"react": "18.1.0",
"react-native": "0.70.3",
"react-native-fs": "^2.20.0",
"realm": "^11.0.0"
OS: macOS Monterey 12.6 , NodeJS 16.x , Xcode 14.0.1
Could you please help me on this. I truly appreciate any suggestions or comments as well.
When I try to run the app, it crashes with the error below? I tried several methods for clearing the cashes, including uninstalling the resent package I installed on the app, but I couldn't figure out what was causing the error or how to fix it.
TypeError: undefined is not a function
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:95:4 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:141:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\#react-native\polyfills\error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules\metro-runtime\src\polyfills\require.js:203:6 in guardedLoadModule
at http://192.168.2.5:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:247928:3 in global code
Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:95:4 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:141:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\#react-native\polyfills\error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:370:8 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:4 in callFunctionReturnFlushedQueue
The following are the recently installed packages:
#react-native-community/datetimepicke
moment
the follwing is my env
Node: 16.15.0
Yarn: 1.22.15
expo: 45.0.0
react: "17.0.2"
react-native: "0.68.2"
So for some reason i'm having this bug when i try to run the app on the Expo Go app in my phone. Apparently is ok if i run on the web browser.
This is the error log
ReferenceError: Can't find variable: TextDecoder
Stack trace:
node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in
error
node_modules\react-native\Libraries\Core\ExceptionsManager.js:95:4 in
reportException
node_modules\react-native\Libraries\Core\ExceptionsManager.js:141:19
in handleException
node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in
handleError
node_modules#react-native\polyfills\error-guard.js:49:36 in
ErrorUtils.reportFatalError
node_modules\metro-runtime\src\polyfills\require.js:203:6 in
guardedLoadModule
http://192.168.0.29:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:190345:3
in global code ...
This happened to us too, on an app that had used to work in an older Expo version. The solution for us was to add this line to our .babelrc.js file:
"presets": [
["babel-preset-expo", {
lazyImports: true, // <<< The fix
]
]
Got over the problem by doing this;
npm install text-encoding
npm install big-integer
and pasting this code inside node_modules>react-native>Libraries>LogBox
const TextEncodingPolyfill = require('text-encoding');
const BigInt = require('big-integer')
Object.assign(global, {
TextEncoder: TextEncodingPolyfill.TextEncoder,
TextDecoder: TextEncodingPolyfill.TextDecoder,
BigInt: BigInt,
});
I am using react-native Expo to build an app and I am trying to use tensorflow.
I tested the code in another (not react-native Expo) project and it worked great!
Unfortunately, in my Expo project it is not working.
The code is:
const threshold = 0.9;
const labelsToInclude = ['identity_attack', 'insult', 'threat'];
toxicity.load(threshold, labelsToInclude).then(model => {
model.classify(['you suck']).then(predictions => {
console.log(JSON.stringify(predictions))
});
});
The code is from: https://medium.com/tensorflow/text-classification-using-tensorflow-js-an-example-of-detecting-offensive-language-in-browser-e2b94e3565ce
I am getting this error:
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (fs.js:592:3)
at tryReadSync (fs.js:366:20)
at Object.readFileSync (fs.js:403:19)
at UnableToResolveError.buildCodeFrameMessage (C:\Users\user\OneDrive\Desktop\n\KidGuard\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:347:17)
at new UnableToResolveError (C:\Users\user\OneDrive\Desktop\n\KidGuard\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:333:35)
at ModuleResolver.resolveDependency (C:\Users\user\OneDrive\Desktop\n\KidGuard\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:211:15)
at DependencyGraph.resolveDependency (C:\Users\user\OneDrive\Desktop\n\KidGuard\node_modules\metro\src\node-haste\DependencyGraph.js:413:43)
at C:\Users\user\OneDrive\Desktop\n\KidGuard\node_modules\metro\src\lib\transformHelpers.js:317:42
at C:\Users\user\OneDrive\Desktop\n\KidGuard\node_modules\metro\src\Server.js:1471:14
at Generator.next (<anonymous>)
right after the error I get this warning:
[Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'environment_1.env().platform.fetch')]
Would love some help!
I have the following error on a jest test that uses react-native and react-native-router-flux
Runtime Error
- TypeError: Cannot read property 'source' of undefined
at Object.<anonymous> (node_modules/react-native-router-flux/src/NavBar.js:155:45)
at Object.<anonymous> (node_modules/react-native-router-flux/src/DefaultRenderer.js:21:13)
at Object.<anonymous> (node_modules/react-native-router-flux/index.js:3:22)
This is the line that causes the trouble
backButtonImage: Image.propTypes.source,
so I guess that Image.propTypes is not defined correct
How can I fix this?