Merge pull request #528 from rmrs/rumors

Workaround for null reference of database reference off
This commit is contained in:
chrisbianca 2017-10-18 10:25:36 +01:00 committed by GitHub
commit 728173c7f1
1 changed files with 5 additions and 3 deletions

View File

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