Skip to content

Commit

Permalink
[ReactNative] Fix switching to null event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiebits authored and ide committed Aug 26, 2015
1 parent 697e96b commit 37386a8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Libraries/ReactNative/ReactNativeBaseComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
}
}
}
},
Expand Down

0 comments on commit 37386a8

Please sign in to comment.