I am doing a watch along project development with the help of https://www.youtube.com/watch?v=bvn_HYpix6s&t=4191s
Around at 1:07:00, we are adding react native imports. we are referring https://reactnativeelements.com/docs.
I have added react-native-safe-area-context npm package.
and did an import as
import { SafeAreaProvider } from 'react-native-safe-area-context';
however doing so, I am getting an error as
Invariant Violation: Tried to register two views with the same name
RNCSafeAreaProvider at
node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in
registerError at
node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in
console.error at
node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in
error at
node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in
reportException at
node_modules\react-native\Libraries\Core\ExceptionsManager.js:171:19
in handleException at
node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in
handleError at
node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in
ErrorUtils.setGlobalHandler$argument_0 at
node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch at
node_modules\regenerator-runtime\runtime.js:294:29 in invoke at
node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch at
node_modules\regenerator-runtime\runtime.js:155:27 in invoke at
node_modules\regenerator-runtime\runtime.js:165:18 in
PromiseImpl.resolve.then$argument_0 at
node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13
in tryCallOne at
node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0 at
node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in
_callTimer at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in
_callImmediatesPass
As per suggestion of few forums I have reinstalled the package but same error.
below is the code snippet I wanted to run.
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Provider } from 'react-redux';
import HomeScreen from './screens/HomeScreen';
import {store} from './store'
import { SafeAreaProvider } from 'react-native-safe-area-context';
export default function App() {
return (
<Provider store={store}>
<SafeAreaProvider >
<HomeScreen/>
</SafeAreaProvider >
</Provider>
);
}
below is the screenshot of mobile emulator.
Regards,
Ashish
it seems react-native-safe-area-context is duplicated.
if you installed #react-native-community/masked-view, it will also install react-native-safe-area-context as a dependency.
If the 2 version is different, you would get such a issue.
Please uninstall react-native-safe-area-context.
Then it will work fine.
As said here, Add the following line on the scripts part, on your package.json:
"postinstall":"rm -rf node_modules/expo/node_modules/react-native-safe-area-context"
If, you're not using expo:
"postinstall":"rm -rf node_modules/react-native-safe-area-context"
Related
ERRORTypeError: undefined is not a function,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 = 10):Systrace, JSTimers,
HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter,
RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient.
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
ERROR Invariant Violation: Failed to call into JavaScript module method
AppRegistry.runApplication(). Module has not
been registered as callable. Registered callable JavaScript modules (n = 10):
Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog,
RCTDeviceEventEmitter, RCTNativeAppEventEmitter,
GlobalPerformanceLogger,JSDevSupportModule, HMRClient.
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
The above paragraph is my Error and I'have tried all the ways known .Can any one explain or tell me How to Resolve it?
/**
* #format
*/
import {AppRegistry} from 'react-native';
import Apps from './App';
import App from './App';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);
"This is my index.js file"
_____________APP.JS__________________
import { View, Text } from 'react-native'
import React from 'react';
import { Provider } from 'react-redux';
import store from './src/store';
import RootNavi from './src/redux/rootNavi.js';
function Apps() {
return (
<Provider store={store}>
<RootNavi/>
</Provider>
)
}
export default Apps
this is my APP.JS file
I am using react native under expo and have installed the required dependencies to install navigator. This is my code:
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, SafeAreaView } from 'react-native';
import Landing from './components/Landing';
import Beach from './components/Beach';
import { createStackNavigator } from '#react-navigation/stack';
export default function App() {
return (
<Landing></Landing>
);
}
If I compile this, I am getting this error:
Error: [BABEL] G:\IntrotoIT\beach-app\node_modules\#react-navigation\stack\src\index.tsx: You gave us a visitor for the node type TSInstantiationExpression but it's not a valid type
at verify (C:\Users\Lenovo\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#babel\traverse\lib\visitors.js:108:13)
at Function.explode (C:\Users\Lenovo\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#babel\traverse\lib\visitors.js:30:3)
at C:\Users\Lenovo\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#babel\core\lib\config\full.js:269:42
at Generator.next (<anonymous>)
at Function.<anonymous> (C:\Users\Lenovo\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#babel\core\lib\gensync-utils\async.js:24:3)
at Generator.next (<anonymous>)
at evaluateSync (C:\Users\Lenovo\AppData\Roaming\npm\node_modules\expo-cli\node_modules\gensync\index.js:251:28)
at Function.sync (C:\Users\Lenovo\AppData\Roaming\npm\node_modules\expo-cli\node_modules\gensync\index.js:89:14)
at sync (C:\Users\Lenovo\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#babel\core\lib\gensync-utils\async.js:67:25)
I seriously don't have clue on how to fix it. Tried deleting node modules and then npm install but it was of no use.
Thanks
Hello I am new at React Native and in my application I am trying to scan ble devices and list their names on screen. In code sources people most commonly create a Bluetooth Low Energy Manager as const manager = new BleManager(); but when I tried this code (and of course other ways too) it gives error like
TypeError: null is not an object (evaluating '_BleModule.BleModule.createClient')
This error is located at:
in HelloWorldApp (created by ExpoRoot)
in ExpoRoot
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
at node_modules\react-native\Libraries\LogBox\LogBox.js:149:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:60:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:34:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
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\ReactFiberErrorDialog.js:43:2 in showErrorDialog
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:15792:34 in logCapturedError
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:15884:20 in update.callback
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:7199:2 in callCallback
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:7220:20 in commitUpdateQueue
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:16632:25 in commitLifeCycles
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:19216:22 in commitLayoutEffects
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:93:4 in invokeGuardedCallbackProd
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:318:2 in invokeGuardedCallback
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18952:29 in commitRootImpl
at node_modules\scheduler\cjs\scheduler.development.js:468:23 in unstable_runWithPriority
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18791:17 in commitRoot
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:18192:12 in performSyncWorkOnRoot
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5911:33 in runWithPriority$argument_1
at node_modules\scheduler\cjs\scheduler.development.js:468:23 in unstable_runWithPriority
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5906:23 in flushSyncCallbackQueueImpl
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:5893:28 in flushSyncCallbackQueue
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:17745:30 in scheduleUpdateOnFiber
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:21484:23 in updateContainer
at node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:22144:17 in render
at node_modules\react-native\Libraries\ReactNative\renderApplication.js:58:4 in renderApplication
at node_modules\react-native\Libraries\ReactNative\AppRegistry.js:117:25 in runnables.appKey.run
at node_modules\react-native\Libraries\ReactNative\AppRegistry.js:202:4 in runApplication
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue
Here is my code that I tried to create a manager:
import { StatusBar } from 'expo-status-bar';
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { BleManager } from 'react-native-ble-plx';
const HelloWorldApp = () => {
const manager = new BleManager();
I cannot solve where is my mistake. Please anyone can help me to solve this issue?
Note: I also installed ble-plx package using npm install --save react-native-ble-plx command.
Note2:I created my project using expo.
You might need to ask the user for permission before using Bluetooth. Add these to your android-manifest.xml :
<uses-feature android:name="android.hardware.bluetooth" android:required="true"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
You are getting this error because of the expo. Expo does not support the ble-manager ble-plx package. You need to create a native project via
npx react-native init AwesomeProject
I would like to use react-native-video in my app. However, what I've done doesn't work :
I created a new project using expo init Project1
Then I installed react-native-video : npm install --save react-native-video
I used then this : react-native link react-native-video
I only have for the moment App.js :
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Video from 'react-native-video';
export default function App() {
return (
<View style={styles.container}>
<Video source={{uri: './small.mp4'}} // Can be a URL or a local file.
ref={(ref) => {
this.player = ref
}} // Store reference
o.nBuffer={this.onBuffer} // Callback when remote video is buffering
onError={this.videoError} // Callback when video cannot be loaded
style={styles.backgroundVideo} />
</View>
);
}
Finally I use npm start
I have this error message :
undefined is not an object (evaluating 'RCTVideoInstance.Constants')
Stack trace:
node_modules/react-native-video/Video.js:265:11 in render
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:13042:21 in finishClassComponent
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:12970:4 in updateClassComponent
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:307:15 in invokeGuardedCallbackImpl
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:531:36 in invokeGuardedCallback
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20488:8 in beginWork$$1
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19370:24 in performUnitOfWork
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19347:39 in workLoopSync
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18997:22 in renderRoot
[native code]:null in renderRoot
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18709:28 in runRootCallback
[native code]:null in runRootCallback
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5642:32 in runWithPriority$argument_1
node_modules/scheduler/cjs/scheduler.development.js:643:23 in unstable_runWithPriority
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5638:22 in flushSyncCallbackQueueImpl
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5627:28 in flushSyncCallbackQueue
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18556:30 in scheduleUpdateOnFiber
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:21822:15 in scheduleRootUpdate
node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:23042:20 in ReactNativeRenderer.render
node_modules/react-native/Libraries/ReactNative/renderApplication.js:52:52 in renderApplication
node_modules/react-native/Libraries/ReactNative/AppRegistry.js:116:10 in runnables.appKey.run
node_modules/react-native/Libraries/ReactNative/AppRegistry.js:197:26 in runApplication
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:436:47 in __callFunction
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:26 in __guard$argument_0
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:110:17 in __guard$argument_0
[native code]:null in callFunctionReturnFlushedQueue
...
I followed instructions from react-native-video : https://www.npmjs.com/package/react-native-video
Thanks a lot...
You have to eject your app from expo and use the bare workflow if you want to use "react-native-video".
Btw, you can use Expo Video instead of react-native-video : https://docs.expo.io/versions/latest/sdk/video/
You can add jcenter to android/build.gradle like this:
allprojects {
repositories {
.... # Keep the rest
jcenter() {
content {
includeModule("com.yqritc", "android-scalablevideoview")
}
}
}
}
This is worked for me hope it will also do your work
The code in app.js file with import statements for react redux is created to display a header with a text called "Tech stack".
App.js
import React from 'react';
import { View } from 'react-native';
import { Header } from './components/common';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from './reducers';
const App = () => {
return(
<Provider store={createStore(reducers)}>
<View>
<Header headerText="Tech Stack" />
</View>
</Provider>
);
};
export default App;
This is the index file
index.js
import { AppRegistry } from 'react-native';
import App from './src/App';
AppRegistry.registerComponent(tech_stack, () => App);
While running this on the terminal, it throws a error saying unable to resolve module 'react-redux'.
Close the JS bundle(a terminal starts when you run app for first time) and rerun it using the command react-native start from the project path. Basically, you need to rerun the JS bundle after every package installation.
Install 'react-redux' by using
npm install --save react-redux
if you not installed it. By seeing your comment as you mentioned that you installed redux only.
Then restart the JS bundle by using
react-native start --reset-cache
I've faced this issue just now. actually, Our (you and I) main issue is naming the global state folder name is redux and the bundler falls in a conflict because there is a folder inside node_modules that name is redux too.
In fact, the main issue is this line:
import { createStore } from 'redux';
I renamed the resux stuffs folder to reduxStore instead of redux and then everything works properly.
This error occurs because you do not have Redux-Thunk middleware installed on your application. To install run:
npm install redux-thunk
Then, restart your application:
react-native start
More information: https://github.com/reduxjs/redux-thunk
I just ran into this problem and solved it by installing redux in addition to react-redux. Apparently, react-redux requires it.