[ReactNative] Fix switching to null event listener

This commit is contained in:
Ben Alpert 2015-08-19 13:44:22 -07:00
parent f4c7bb1103
commit 0f3ea9fb8c
1 changed files with 6 additions and 1 deletions

View File

@ -27,6 +27,7 @@ var warning = require('warning');
var registrationNames = ReactNativeEventEmitter.registrationNames;
var putListener = ReactNativeEventEmitter.putListener;
var deleteListener = ReactNativeEventEmitter.deleteListener;
var deleteAllListeners = ReactNativeEventEmitter.deleteAllListeners;
type ReactNativeBaseComponentViewConfig = {
@ -230,7 +231,11 @@ ReactNativeBaseComponent.Mixin = {
_reconcileListenersUponUpdate: function(prevProps, nextProps) {
for (var key in nextProps) {
if (registrationNames[key] && (nextProps[key] !== prevProps[key])) {
putListener(this._rootNodeID, key, nextProps[key]);
if (nextProps[key]) {
putListener(this._rootNodeID, key, nextProps[key]);
} else {
deleteListener(this._rootNodeID, key);
}
}
}
},