Expo React Native Can't find variable: TextDecoder - react-native

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,
});

Related

TypeError: Cannot read property 'createDrawerNavigator' of undefined

When I' using the react navigation version 6.1.1. I face this error.
TypeError: Cannot read property 'createDrawerNavigator' of undefined
I have import the createDrawerNavigator from #react-navigation/drawer. But When I start the app the I saw this error TypeError: Cannot read property 'createDrawerNavigator' of undefined. How can I solve this error?
Screenshot of the error
We have to import the gesture handler in the main index file. like this
import 'react-native-gesture-handler';
install "react-native-reanimated" and config your bable.config file
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'react-native-reanimated/plugin'
],
};
and then
pod install
yarn start --reset-cache
Open your android folder in android studio, then run from there.

Error in opening a pre-filled realm db in react-native app - TypeError: undefined is not a function in asyncGeneratorStep

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.

Frame Processor threw an error: Value is undefined, expected an Object

In react native Project i installed react-native-vision-camera and react-native reanimated and then react-native-hole after running the project it gives me the error Frame Processor threw an error: Value is undefined, expected an Object
though camera is opened but it comes repeatedly the error, Please help to overcome the solution...i want to make the QR Code Scanner ...the react native QRScanner is getting deprecated please help for making QR Scanner in React Native ..Please help
I solved this issue by following these steps-
Change in your babel config-
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
// <-- this
'react-native-reanimated/plugin',
{
globals: ['__scanCodes'],
},
],
],
};
npm start -- --reset-cache
add import 'react-native-reanimated'; at the top on index.js file

TypeError: undefined is not a function react native expo

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"

One Signal SDK Error with Expo+ReactNative

I'm trying to add the OneSignal SDK to my ReactNative project managed by Expo SDK, by following the guide here:
Expo One Signal
here is my plugin setup in App.js
export default function App() {
useEffect(() => {
///Other things
OneSignal.setAppId(Constants.manifest.extra.oneSignalAppId);
}, []);
unfortunately it doesn't work, first I was getting:
Invariant Violation: Native module cannot be null.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172: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:204:6 in guardedLoadModule
at http://127.0.0.1:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:263808: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/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172: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
Then, after opening an issue in GitHub the author suggested my to install:
yarn add react-native-onesignal
Here is the Issue on Github.Then I started getting:
iOS Bundling failed 3417ms
Unable to resolve module fs from /Users/giulioserra/Documents/App/CTS/node_modules/onesignal-expo-plugin/build/onesignal/withOneSignalIos.js: fs could not be found within the project or in these directories:
node_modules
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
29 | exports.xcodeProjectAddNse = exports.withOneSignalIos = void 0;
30 | const config_plugins_1 = require("#expo/config-plugins");
> 31 | const fs = __importStar(require("fs"));
I cleared the cache but nothing, It seems so strange since fs package should be included in every node release as far as I know, and suggestions?