Remove fbjs/lib/emptyFunction from react-native

Summary: This removes `emptyFunction` usage from react-native.

Reviewed By: yungsters

Differential Revision: D13138187

fbshipit-source-id: eaa327884aac2cabb99024077e3407cb99c946d2
This commit is contained in:
Christoph Nakazawa 2018-11-26 06:24:05 -08:00 committed by Facebook Github Bot
parent 2de01cb54d
commit cfef04e760
3 changed files with 11 additions and 11 deletions

View File

@ -26,7 +26,6 @@ const TouchableWithoutFeedback = require('TouchableWithoutFeedback');
const UIManager = require('UIManager'); const UIManager = require('UIManager');
const createReactClass = require('create-react-class'); const createReactClass = require('create-react-class');
const emptyFunction = require('fbjs/lib/emptyFunction');
const invariant = require('fbjs/lib/invariant'); const invariant = require('fbjs/lib/invariant');
const requireNativeComponent = require('requireNativeComponent'); const requireNativeComponent = require('requireNativeComponent');
const warning = require('fbjs/lib/warning'); const warning = require('fbjs/lib/warning');
@ -276,6 +275,8 @@ type Props = $ReadOnly<{|
contextMenuHidden?: ?boolean, contextMenuHidden?: ?boolean,
|}>; |}>;
const emptyFunctionThatReturnsTrue = () => true;
/** /**
* A foundational component for inputting text into the app via a * A foundational component for inputting text into the app via a
* keyboard. Props provide configurability for several features, such as * keyboard. Props provide configurability for several features, such as
@ -999,7 +1000,7 @@ const TextInput = createReactClass({
onBlur={this._onBlur} onBlur={this._onBlur}
onChange={this._onChange} onChange={this._onChange}
onSelectionChange={this._onSelectionChange} onSelectionChange={this._onSelectionChange}
onSelectionChangeShouldSetResponder={emptyFunction.thatReturnsTrue} onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
text={this._getText()} text={this._getText()}
/> />
); );
@ -1036,7 +1037,7 @@ const TextInput = createReactClass({
onContentSizeChange={this.props.onContentSizeChange} onContentSizeChange={this.props.onContentSizeChange}
onSelectionChange={this._onSelectionChange} onSelectionChange={this._onSelectionChange}
onTextInput={this._onTextInput} onTextInput={this._onTextInput}
onSelectionChangeShouldSetResponder={emptyFunction.thatReturnsTrue} onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
text={this._getText()} text={this._getText()}
dataDetectorTypes={this.props.dataDetectorTypes} dataDetectorTypes={this.props.dataDetectorTypes}
onScroll={this._onScroll} onScroll={this._onScroll}
@ -1089,7 +1090,7 @@ const TextInput = createReactClass({
onContentSizeChange={this.props.onContentSizeChange} onContentSizeChange={this.props.onContentSizeChange}
onSelectionChange={this._onSelectionChange} onSelectionChange={this._onSelectionChange}
onTextInput={this._onTextInput} onTextInput={this._onTextInput}
onSelectionChangeShouldSetResponder={emptyFunction.thatReturnsTrue} onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue}
text={this._getText()} text={this._getText()}
dataDetectorTypes={this.props.dataDetectorTypes} dataDetectorTypes={this.props.dataDetectorTypes}
onScroll={this._onScroll} onScroll={this._onScroll}

View File

@ -17,8 +17,6 @@ const React = require('React');
const StyleSheet = require('StyleSheet'); const StyleSheet = require('StyleSheet');
const View = require('View'); const View = require('View');
const emptyFunction = require('fbjs/lib/emptyFunction');
import type {LayoutEvent, PressEvent} from 'CoreEventTypes'; import type {LayoutEvent, PressEvent} from 'CoreEventTypes';
import type {GestureState} from 'PanResponder'; import type {GestureState} from 'PanResponder';
@ -55,6 +53,8 @@ const RIGHT_SWIPE_BOUNCE_BACK_DURATION = 300;
const RIGHT_SWIPE_THRESHOLD = 30 * SLOW_SPEED_SWIPE_FACTOR; const RIGHT_SWIPE_THRESHOLD = 30 * SLOW_SPEED_SWIPE_FACTOR;
const DEFAULT_SWIPE_THRESHOLD = 30; const DEFAULT_SWIPE_THRESHOLD = 30;
const emptyFunction = () => {};
type Props = $ReadOnly<{| type Props = $ReadOnly<{|
children?: ?React.Node, children?: ?React.Node,
isOpen?: ?boolean, isOpen?: ?boolean,

View File

@ -14,9 +14,10 @@
const EmitterSubscription = require('EmitterSubscription'); const EmitterSubscription = require('EmitterSubscription');
const EventSubscriptionVendor = require('EventSubscriptionVendor'); const EventSubscriptionVendor = require('EventSubscriptionVendor');
const emptyFunction = require('fbjs/lib/emptyFunction');
const invariant = require('fbjs/lib/invariant'); const invariant = require('fbjs/lib/invariant');
const emptyFunctionThatReturnsTrue = () => true;
/** /**
* @class EventEmitter * @class EventEmitter
* @description * @description
@ -155,10 +156,8 @@ class EventEmitter {
] = (this._subscriber.getSubscriptionsForType(eventType): any); ] = (this._subscriber.getSubscriptionsForType(eventType): any);
return subscriptions return subscriptions
? subscriptions ? subscriptions
.filter(emptyFunction.thatReturnsTrue) .filter(emptyFunctionThatReturnsTrue)
.map(function(subscription) { .map(subscription => subscription.listener)
return subscription.listener;
})
: []; : [];
} }