temporary fix to the reference off bug

This commit is contained in:
Omer Levy 2017-10-18 11:27:55 +03:00
parent 60a9f879ff
commit e4ae2609da
1 changed files with 5 additions and 3 deletions

View File

@ -416,10 +416,12 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
@ReactMethod
public void off(String key, String eventRegistrationKey) {
RNFirebaseDatabaseReference nativeRef = references.get(key);
nativeRef.removeEventListener(eventRegistrationKey);
if (nativeRef) {
nativeRef.removeEventListener(eventRegistrationKey);
if (!nativeRef.hasListeners()) {
references.remove(key);
if (!nativeRef.hasListeners()) {
references.remove(key);
}
}
}