当我使用以下代码在我的react-native产品中的App.js代码内调用react-native-ble-plx软件包时:
this.manager = new BleManager();
它引发以下错误:
TypeError: undefined is not an object (evaluating '_BleModule.BleModule.createClient')
This error is located at:
in DashboardScreen (at App.js:17)
in App (at withExpoRoot.js:22)
in RootErrorBoundary (at withExpoRoot.js:21)
in ExpoRootComponent (at renderApplication.js:34)
in RCTView (at View.js:44)
in RCTView (at View.js:44)
in AppContainer (at renderApplication.js:33)
- node_modules/react-native-ble-plx/src/BleManager.js:91:14 in BleManager
* screens/DashboardScreen.js:15:19 in scanAndConnect
* screens/DashboardScreen.js:55:4 in render
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:10563:21 in finishClassComponent
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:14091:21 in performUnitOfWork
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:14129:41 in workLoop
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:14226:15 in renderRoot
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:15193:17 in performWorkOnRoot
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:15090:24 in performWork
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:15047:14 in performSyncWork
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:14925:19 in requestWork
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:14711:16 in scheduleWork
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:15429:15 in scheduleRootUpdate
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:16142:20 in render
- node_modules/react-native/Libraries/ReactNative/renderApplication.js:59:52 in renderApplication
- node_modules/react-native/Libraries/ReactNative/AppRegistry.js:101:10 in run
- node_modules/react-native/Libraries/ReactNative/AppRegistry.js:195:26 in runApplication
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:349:47 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:106:26 in <unknown>
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:297:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:105:17 in callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
我已经按照https://github.com/Polidea/react-native-ble-plx中文档的步骤进行操作,所以我不知道发生了什么,请帮忙! :(
版本:
节点v10.16.0
npm 6.9.0
博览会^ 32.0.0
expokit ^ 32.1.1
react-native-ble-plx 1.0.3
react-native-cli 2.0.1
本机0.57.1
更新:
作为一个团队,我们发现错误是expo与react-native-ble-plx不兼容,因此我们改为使用纯react-native(地铁捆绑器)。小心使用expo!