You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug isBeingObserved is always false below RN 0.65, Because addListener will not execute.
public class RNSensor extends ReactContextBaseJavaModule implements SensorEventListener {
...
private Boolean isBeingObserved = false;
...
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
if(!isBeingObserved) {
return; // avoid all the computation if there are no observers
}
...
}
...
// this is called by RN when the first listener is registered
// not implementing this method will cause a warning on RN 0.65 onwards
@ReactMethod
public void addListener(String eventName) {
isBeingObserved = true;
}
// this is called by RN when the last listener is deregistered
// not implementing this method will cause a warning on RN 0.65 onwards
@ReactMethod
public void removeListeners(Integer count) {
isBeingObserved = false;
stopUpdates(); // maybe only calling `stopUpdates()` is enough
}
}
To Reproduce
Steps to reproduce the behavior:
Go to '...'
Click on '....'
Scroll down to '....'
See error
Expected behavior
A clear and concise description of what you expected to happen.
Desktop (please complete the following information):
React Native Version: [e.g. 0.63.3]
Device [e.g. real android device]
Version [e.g. 7.3.6]
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Describe the bug
isBeingObserved
is always false below RN 0.65, BecauseaddListener
will not execute.To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: