Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FabricViewStateManager: setState called without a StateWrapper

I am an iOS developer venturing into Android dfor the first time using React-native.

I am creating a react-native app that uses bluetooth-le, using polidieas react-native-ble-plx library. iOS app works fine, bluetooth scans and detecgts devices. When i run on Android, it starts to scan and I receive an error "FabricViewStateManager: setState called without a StateWrapper" and cannot find any documentation or help for this error statement.

Two questions:

  1. has anyone seen this error reported when running React-Native Apps on Anmdroid: FabricViewStateManager: setState called without a StateWrapper.

  2. Does anyone have any thoughts on how to isolate where the error is occurring?

Here is the console right before the error:

I/BluetoothAdapter: STATE_ON
I/BluetoothAdapter: STATE_ON
I/BluetoothAdapter: STATE_ON
I/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Start Scan with callback
D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=13 mScannerId=0
I/ReactNative: [GESTURE HANDLER] Initialize gesture handler for root view com.facebook.react.ReactRootView{67ef486 V.E...... ......ID 0,0-1080,2019 #1}
**E/unknown:FabricViewStateManager: setState called without a StateWrapper**
I/ReactNativeJS: ┐ %c action %cCHANGE_STATUS %c@ 20:36:54.384
I/ReactNativeJS: │ '%c prev state', 'color: #9E9E9E; font-weight: bold', { BLEs: 
       { BLEList: [],
         color: '#800080',
         oldColor: '#000000',
         intensity: 127,
         connectedDevice: {},
         status: 'disconnected' } }
    │ '%c action    ', 'color: #03A9F4; font-weight: bold', { type: 'CHANGE_STATUS', status: 'Scanning' }
I/ReactNativeJS: │ '%c next state', 'color: #4CAF50; font-weight: bold', { BLEs: 
       { BLEList: [],
         color: '#800080',
         oldColor: '#000000',
         intensity: 127,
         connectedDevice: {},
         status: 'Scanning' } }
    ┘ 
    ┐ %c action %cADD_BLE %c@ 20:36:54.391
I/ReactNativeJS: │ '%c prev state', 'color: #9E9E9E; font-weight: bold', { BLEs: 
       { BLEList: [],
         color: '#800080',
         oldColor: '#000000',
         intensity: 127,
         connectedDevice: {},
         status: 'Scanning' } }
I/ReactNativeJS: │ '%c action    ', 'color: #03A9F4; font-weight: bold', { type: 'ADD_BLE',
      device: 
like image 645
Bob O Avatar asked Aug 11 '21 01:08

Bob O


People also ask

Can I pass function instead of object in setState ()?

setState is asynchronous call means if synchronous call get called it may not get updated at right time like to know current value of object after update using setState it may not get give current updated value on console. To get some behavior of synchronous need to pass function instead of object to setState.

Why do we need to pass a function to setState ()?

Why we need to pass a function to setState()? The reason behind for this is that setState() is an asynchronous operation. React batches state changes for performance reasons, so the state may not change immediately after setState() is called.

Can setState take a function?

The Solution The setState function takes an optional callback parameter that can be used to make updates after the state is changed. This function will get called once the state has been updated, and the callback will receive the updated value of the state.

Why is it better to pass a function to setState instead of an object?

Passing in a function into setState instead of an object will give you a reliable value for your component's state and props .


1 Answers

To my knowledge there is no answer for this yet. See this issue posted against the facebook/react-native project in GitHub: https://github.com/facebook/react-native/issues/32070.

It may have something to do with react-native-reanimated, if you're using it, which has been the cause of some cryptic crashes with the latest version of RN (see here and here, for example). They've apparently resolved the issues in the recent 2.2.2 release (on 14 SEP 21) and their 2.3.0-alpha.

like image 197
jetsetter Avatar answered Sep 20 '22 14:09

jetsetter