Skip to content

Commit c0e489b

Browse files
bradzacherfacebook-github-bot
authored andcommitted
remove duplicate class members
Summary: Flow currently allows duplicate members on classes. At runtime the "last" member wins out and all previous values for the member are discarded. This diff manually removes duplicate members, and fixes resulting flow errors by converting methods to arrow function properties. Reviewed By: pieterv Differential Revision: D33664966 fbshipit-source-id: 0f712ac96af4df593c0918fcbadd70624ddde4a6
1 parent b13e41d commit c0e489b

File tree

4 files changed

+8
-37
lines changed

4 files changed

+8
-37
lines changed

Libraries/Animated/AnimatedEvent.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ function validateMapping(argMapping, args) {
145145
class AnimatedEvent {
146146
_argMapping: $ReadOnlyArray<?Mapping>;
147147
_listeners: Array<Function> = [];
148-
_callListeners: Function;
149148
_attachedEvent: ?{detach: () => void, ...};
150149
__isNative: boolean;
151150

@@ -160,7 +159,6 @@ class AnimatedEvent {
160159
if (config.listener) {
161160
this.__addListener(config.listener);
162161
}
163-
this._callListeners = this._callListeners.bind(this);
164162
this._attachedEvent = null;
165163
this.__isNative = shouldUseNativeDriver(config);
166164
}
@@ -245,9 +243,9 @@ class AnimatedEvent {
245243
};
246244
}
247245

248-
_callListeners(...args: any) {
246+
_callListeners = (...args: any) => {
249247
this._listeners.forEach(listener => listener(...args));
250-
}
248+
};
251249
}
252250

253251
module.exports = {AnimatedEvent, attachNativeEvent};

Libraries/Network/XMLHttpRequest.js

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ class XMLHttpRequest extends (EventTarget(...XHR_EVENTS): any) {
136136
_lowerCaseResponseHeaders: Object;
137137
_method: ?string = null;
138138
_perfKey: ?string = null;
139-
_response: string | ?Object;
140139
_responseType: ResponseType;
141140
_response: string = '';
142141
_sent: boolean;

packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExApp.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,16 @@ const NUM_CIRCLES = 30;
2828
class Circle extends React.Component<any, any> {
2929
longTimer: number;
3030

31-
_onLongPress: () => void;
32-
_toggleIsActive: () => void;
3331
constructor(props: Object): void {
3432
super();
35-
this._onLongPress = this._onLongPress.bind(this);
36-
this._toggleIsActive = this._toggleIsActive.bind(this);
3733
this.state = {
3834
isActive: false,
3935
pan: new Animated.ValueXY(), // Vectors reduce boilerplate. (step1: uncomment)
4036
pop: new Animated.Value(0), // Initial value. (step2a: uncomment)
4137
};
4238
}
4339

44-
_onLongPress(): void {
40+
_onLongPress = (): void => {
4541
const config = {tension: 40, friction: 3};
4642
this.state.pan.addListener(value => {
4743
// Async listener for state changes (step1: uncomment)
@@ -90,7 +86,7 @@ class Circle extends React.Component<any, any> {
9086
this.props.onActivate();
9187
},
9288
);
93-
}
89+
};
9490

9591
render(): React.Node {
9692
let handlers;
@@ -193,7 +189,7 @@ class Circle extends React.Component<any, any> {
193189
</Animated.View>
194190
);
195191
}
196-
_toggleIsActive(velocity) {
192+
_toggleIsActive = velocity => {
197193
const config = {tension: 30, friction: 7};
198194
if (this.state.isActive) {
199195
Animated.spring(this.props.openVal, {
@@ -215,11 +211,10 @@ class Circle extends React.Component<any, any> {
215211
}).start(); // (step4: uncomment)
216212
});
217213
}
218-
}
214+
};
219215
}
220216

221217
class AnExApp extends React.Component<any, any> {
222-
_onMove: (position: Point) => void;
223218
constructor(props: any): void {
224219
super(props);
225220
const keys = [];
@@ -231,7 +226,6 @@ class AnExApp extends React.Component<any, any> {
231226
restLayouts: [],
232227
openVal: new Animated.Value(0),
233228
};
234-
this._onMove = this._onMove.bind(this);
235229
}
236230

237231
render(): React.Node {
@@ -297,13 +291,13 @@ class AnExApp extends React.Component<any, any> {
297291
);
298292
}
299293

300-
_onMove(position: Point): void {
294+
_onMove = (position: Point): void => {
301295
const newKeys = moveToClosest(this.state, position);
302296
if (newKeys !== this.state.keys) {
303297
LayoutAnimation.easeInEaseOut(); // animates layout update as one batch (step3: uncomment)
304298
this.setState({keys: newKeys});
305299
}
306-
}
300+
};
307301
}
308302

309303
type Point = {

packages/rn-tester/js/examples/Image/ImageExample.js

-20
Original file line numberDiff line numberDiff line change
@@ -339,16 +339,6 @@ class MultipleSourcesExample extends React.Component<
339339
});
340340
};
341341

342-
increaseImageSize = () => {
343-
if (this.state.width >= 100) {
344-
return;
345-
}
346-
this.setState({
347-
width: this.state.width + 10,
348-
height: this.state.height + 10,
349-
});
350-
};
351-
352342
decreaseImageSize = () => {
353343
if (this.state.width <= 10) {
354344
return;
@@ -480,16 +470,6 @@ class OnLayoutExample extends React.Component<
480470
});
481471
};
482472

483-
increaseImageSize = () => {
484-
if (this.state.width >= 100) {
485-
return;
486-
}
487-
this.setState({
488-
width: this.state.width + 10,
489-
height: this.state.height + 10,
490-
});
491-
};
492-
493473
decreaseImageSize = () => {
494474
if (this.state.width <= 10) {
495475
return;

0 commit comments

Comments
 (0)