From 38d2109f24644d0c4065a9e67bb8fe386b187af7 Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Thu, 27 Sep 2018 14:03:07 -0400 Subject: [PATCH 01/10] TVViewPropTypes, PlatformViewPropTypes, DeprecatedTVViewPropTypes --- .../Components/AppleTV/TVViewPropTypes.js | 53 +++++-------- .../View/PlatformViewPropTypes.android.js | 13 ++++ .../View/PlatformViewPropTypes.ios.js | 15 ++++ .../Components/View/PlatformViewPropTypes.js | 21 ----- .../DeprecatedTVViewPropTypes.js | 76 +++++++++++++++++++ 5 files changed, 125 insertions(+), 53 deletions(-) create mode 100644 Libraries/Components/View/PlatformViewPropTypes.android.js create mode 100644 Libraries/Components/View/PlatformViewPropTypes.ios.js delete mode 100644 Libraries/Components/View/PlatformViewPropTypes.js create mode 100644 Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js diff --git a/Libraries/Components/AppleTV/TVViewPropTypes.js b/Libraries/Components/AppleTV/TVViewPropTypes.js index 764dfbb8ac5d..3d30fbaffa3d 100644 --- a/Libraries/Components/AppleTV/TVViewPropTypes.js +++ b/Libraries/Components/AppleTV/TVViewPropTypes.js @@ -1,30 +1,34 @@ /** - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. * - * @format + * @providesModule TVViewPropTypes * @flow */ - 'use strict'; -const PropTypes = require('prop-types'); /** * Additional View properties for Apple TV */ -const TVViewPropTypes = { +export type TVViewProps = { /** - * When set to true, this view will be focusable - * and navigable using the TV remote. + * *(Apple TV only)* When set to true, this view will be focusable + * and navigable using the Apple TV remote. + * + * @platform ios */ - isTVSelectable: PropTypes.bool, + isTVSelectable?: bool, /** - * May be set to true to force the TV focus engine to move focus to this view. + * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view. + * + * @platform ios */ - hasTVPreferredFocus: PropTypes.bool, + hasTVPreferredFocus?: bool, /** * *(Apple TV only)* Object with properties to control Apple TV parallax effects. @@ -34,51 +38,36 @@ const TVViewPropTypes = { * shiftDistanceY: Defaults to 2.0. * tiltAngle: Defaults to 0.05. * magnification: Defaults to 1.0. - * pressMagnification: Defaults to 1.0. - * pressDuration: Defaults to 0.3. - * pressDelay: Defaults to 0.0. * * @platform ios */ - tvParallaxProperties: PropTypes.object, + tvParallaxProperties?: Object, /** * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. * * @platform ios */ - tvParallaxShiftDistanceX: PropTypes.number, + tvParallaxShiftDistanceX?: number, /** * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. * * @platform ios */ - tvParallaxShiftDistanceY: PropTypes.number, + tvParallaxShiftDistanceY?: number, /** * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05. * * @platform ios */ - tvParallaxTiltAngle: PropTypes.number, + tvParallaxTiltAngle?: number, /** * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0. * * @platform ios */ - tvParallaxMagnification: PropTypes.number, -}; - -export type TVViewProps = $ReadOnly<{| - isTVSelectable?: boolean, - hasTVPreferredFocus?: boolean, - tvParallaxProperties?: Object, - tvParallaxShiftDistanceX?: number, - tvParallaxShiftDistanceY?: number, - tvParallaxTiltAngle?: number, tvParallaxMagnification?: number, -|}>; - -module.exports = TVViewPropTypes; +}; \ No newline at end of file diff --git a/Libraries/Components/View/PlatformViewPropTypes.android.js b/Libraries/Components/View/PlatformViewPropTypes.android.js new file mode 100644 index 000000000000..9cd254714711 --- /dev/null +++ b/Libraries/Components/View/PlatformViewPropTypes.android.js @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule PlatformViewPropTypes + * @flow + */ + +export type PlatformViewPropTypes = {}; \ No newline at end of file diff --git a/Libraries/Components/View/PlatformViewPropTypes.ios.js b/Libraries/Components/View/PlatformViewPropTypes.ios.js new file mode 100644 index 000000000000..b80b85300b28 --- /dev/null +++ b/Libraries/Components/View/PlatformViewPropTypes.ios.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule PlatformViewPropTypes + * @flow + */ + +import type {TVViewProps} from 'TVViewPropTypes'; + +export type PlatformViewPropTypes = TVViewProps; \ No newline at end of file diff --git a/Libraries/Components/View/PlatformViewPropTypes.js b/Libraries/Components/View/PlatformViewPropTypes.js deleted file mode 100644 index 282465fdcdd4..000000000000 --- a/Libraries/Components/View/PlatformViewPropTypes.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - */ - -const Platform = require('Platform'); - -let TVViewPropTypes = {}; -// We need to always include TVViewPropTypes on Android -// as unlike on iOS we can't detect TV devices at build time -// and hence make view manager export a different list of native properties. -if (Platform.isTV || Platform.OS === 'android') { - TVViewPropTypes = require('TVViewPropTypes'); -} - -module.exports = TVViewPropTypes; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js new file mode 100644 index 000000000000..2a14f100c2d7 --- /dev/null +++ b/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow + * @format + */ +'use strict'; +var PropTypes = require('prop-types'); + +/** + * Additional View properties for Apple TV + */ +var DeprecatedTVViewPropTypes = { + /** + * *(Apple TV only)* When set to true, this view will be focusable + * and navigable using the Apple TV remote. + * + * @platform ios + */ + isTVSelectable: PropTypes.bool, + + /** + * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view. + * + * @platform ios + */ + hasTVPreferredFocus: PropTypes.bool, + + /** + * *(Apple TV only)* Object with properties to control Apple TV parallax effects. + * + * enabled: If true, parallax effects are enabled. Defaults to true. + * shiftDistanceX: Defaults to 2.0. + * shiftDistanceY: Defaults to 2.0. + * tiltAngle: Defaults to 0.05. + * magnification: Defaults to 1.0. + * + * @platform ios + */ + tvParallaxProperties: PropTypes.object, + + /** + * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. + * + * @platform ios + */ + tvParallaxShiftDistanceX: PropTypes.number, + + /** + * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. + * + * @platform ios + */ + tvParallaxShiftDistanceY: PropTypes.number, + + /** + * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05. + * + * @platform ios + */ + tvParallaxTiltAngle: PropTypes.number, + + /** + * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0. + * + * @platform ios + */ + tvParallaxMagnification: PropTypes.number, +}; + +module.exports = DeprecatedTVViewPropTypes; From 415fa86cbcf94029f91988647a6f715d0a9484cc Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Thu, 27 Sep 2018 14:10:06 -0400 Subject: [PATCH 02/10] UPDATE: @format --- Libraries/Components/AppleTV/TVViewPropTypes.js | 7 ++++--- Libraries/Components/View/PlatformViewPropTypes.android.js | 3 ++- Libraries/Components/View/PlatformViewPropTypes.ios.js | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Libraries/Components/AppleTV/TVViewPropTypes.js b/Libraries/Components/AppleTV/TVViewPropTypes.js index 3d30fbaffa3d..02a3282b8a9f 100644 --- a/Libraries/Components/AppleTV/TVViewPropTypes.js +++ b/Libraries/Components/AppleTV/TVViewPropTypes.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule TVViewPropTypes + * @format * @flow */ 'use strict'; @@ -21,14 +22,14 @@ export type TVViewProps = { * * @platform ios */ - isTVSelectable?: bool, + isTVSelectable?: boolean, /** * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view. * * @platform ios */ - hasTVPreferredFocus?: bool, + hasTVPreferredFocus?: boolean, /** * *(Apple TV only)* Object with properties to control Apple TV parallax effects. @@ -70,4 +71,4 @@ export type TVViewProps = { * @platform ios */ tvParallaxMagnification?: number, -}; \ No newline at end of file +}; diff --git a/Libraries/Components/View/PlatformViewPropTypes.android.js b/Libraries/Components/View/PlatformViewPropTypes.android.js index 9cd254714711..6e68229fe36b 100644 --- a/Libraries/Components/View/PlatformViewPropTypes.android.js +++ b/Libraries/Components/View/PlatformViewPropTypes.android.js @@ -7,7 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule PlatformViewPropTypes + * @format * @flow */ -export type PlatformViewPropTypes = {}; \ No newline at end of file +export type PlatformViewPropTypes = {}; diff --git a/Libraries/Components/View/PlatformViewPropTypes.ios.js b/Libraries/Components/View/PlatformViewPropTypes.ios.js index b80b85300b28..642a6d81198b 100644 --- a/Libraries/Components/View/PlatformViewPropTypes.ios.js +++ b/Libraries/Components/View/PlatformViewPropTypes.ios.js @@ -7,9 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule PlatformViewPropTypes + * @format * @flow */ import type {TVViewProps} from 'TVViewPropTypes'; -export type PlatformViewPropTypes = TVViewProps; \ No newline at end of file +export type PlatformViewPropTypes = TVViewProps; From 396b19dde7d936859365c3fabafb4a722bd78f3a Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Thu, 27 Sep 2018 14:17:24 -0400 Subject: [PATCH 03/10] UPDATE: DeprecatedTVViewPropTypes clean + rm comments --- .../DeprecatedTVViewPropTypes.js | 53 +------------------ 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js index 2a14f100c2d7..27e6ee430d41 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js @@ -12,64 +12,13 @@ 'use strict'; var PropTypes = require('prop-types'); -/** - * Additional View properties for Apple TV - */ -var DeprecatedTVViewPropTypes = { - /** - * *(Apple TV only)* When set to true, this view will be focusable - * and navigable using the Apple TV remote. - * - * @platform ios - */ +const DeprecatedTVViewPropTypes = { isTVSelectable: PropTypes.bool, - - /** - * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view. - * - * @platform ios - */ hasTVPreferredFocus: PropTypes.bool, - - /** - * *(Apple TV only)* Object with properties to control Apple TV parallax effects. - * - * enabled: If true, parallax effects are enabled. Defaults to true. - * shiftDistanceX: Defaults to 2.0. - * shiftDistanceY: Defaults to 2.0. - * tiltAngle: Defaults to 0.05. - * magnification: Defaults to 1.0. - * - * @platform ios - */ tvParallaxProperties: PropTypes.object, - - /** - * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. - * - * @platform ios - */ tvParallaxShiftDistanceX: PropTypes.number, - - /** - * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. - * - * @platform ios - */ tvParallaxShiftDistanceY: PropTypes.number, - - /** - * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05. - * - * @platform ios - */ tvParallaxTiltAngle: PropTypes.number, - - /** - * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0. - * - * @platform ios - */ tvParallaxMagnification: PropTypes.number, }; From c62a88fe6963afdf4be77a6eb964349510277739 Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Thu, 27 Sep 2018 14:22:17 -0400 Subject: [PATCH 04/10] UPDATE: TVViewPropTypes header --- Libraries/Components/AppleTV/TVViewPropTypes.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Libraries/Components/AppleTV/TVViewPropTypes.js b/Libraries/Components/AppleTV/TVViewPropTypes.js index 02a3282b8a9f..bea4904a0824 100644 --- a/Libraries/Components/AppleTV/TVViewPropTypes.js +++ b/Libraries/Components/AppleTV/TVViewPropTypes.js @@ -1,15 +1,13 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * - * @providesModule TVViewPropTypes * @format * @flow */ + 'use strict'; /** From 4955d237f677811311de9585098dde9ad28f75f7 Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Thu, 27 Sep 2018 14:33:19 -0400 Subject: [PATCH 05/10] UPDATE: Headers --- .../View/PlatformViewPropTypes.android.js | 10 +++++----- .../Components/View/PlatformViewPropTypes.ios.js | 10 +++++----- .../DeprecatedTVViewPropTypes.js | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Libraries/Components/View/PlatformViewPropTypes.android.js b/Libraries/Components/View/PlatformViewPropTypes.android.js index 6e68229fe36b..f96fe3a62d81 100644 --- a/Libraries/Components/View/PlatformViewPropTypes.android.js +++ b/Libraries/Components/View/PlatformViewPropTypes.android.js @@ -1,14 +1,14 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule PlatformViewPropTypes * @format * @flow */ +'use strict'; + export type PlatformViewPropTypes = {}; diff --git a/Libraries/Components/View/PlatformViewPropTypes.ios.js b/Libraries/Components/View/PlatformViewPropTypes.ios.js index 642a6d81198b..fc8427506010 100644 --- a/Libraries/Components/View/PlatformViewPropTypes.ios.js +++ b/Libraries/Components/View/PlatformViewPropTypes.ios.js @@ -1,16 +1,16 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * * @providesModule PlatformViewPropTypes * @format * @flow */ +'use strict'; + import type {TVViewProps} from 'TVViewPropTypes'; export type PlatformViewPropTypes = TVViewProps; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js index 27e6ee430d41..90af60cc27da 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedTVViewPropTypes.js @@ -1,16 +1,16 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * - * @flow * @format + * @flow */ + 'use strict'; -var PropTypes = require('prop-types'); + +const PropTypes = require('prop-types'); const DeprecatedTVViewPropTypes = { isTVSelectable: PropTypes.bool, From f81976a7c60426a1eda099bd15b702d53e363f85 Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Thu, 27 Sep 2018 14:46:34 -0400 Subject: [PATCH 06/10] UPDATE: TVViewPropTypes tvParallaxProperties --- .../Components/AppleTV/TVViewPropTypes.js | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Libraries/Components/AppleTV/TVViewPropTypes.js b/Libraries/Components/AppleTV/TVViewPropTypes.js index bea4904a0824..5acb26e52385 100644 --- a/Libraries/Components/AppleTV/TVViewPropTypes.js +++ b/Libraries/Components/AppleTV/TVViewPropTypes.js @@ -10,6 +10,33 @@ 'use strict'; +type TVParallaxPropertiesType = { + /** + * If true, parallax effects are enabled. Defaults to true. + */ + enabled: boolean, + + /** + * Defaults to 2.0. + */ + shiftDistanceX: number, + + /** + * Defaults to 2.0. + */ + shiftDistanceY: number, + + /** + * Defaults to 0.05. + */ + tiltAngle: number, + + /** + * Defaults to 1.0 + */ + magnification: number, +}; + /** * Additional View properties for Apple TV */ @@ -32,15 +59,9 @@ export type TVViewProps = { /** * *(Apple TV only)* Object with properties to control Apple TV parallax effects. * - * enabled: If true, parallax effects are enabled. Defaults to true. - * shiftDistanceX: Defaults to 2.0. - * shiftDistanceY: Defaults to 2.0. - * tiltAngle: Defaults to 0.05. - * magnification: Defaults to 1.0. - * * @platform ios */ - tvParallaxProperties?: Object, + tvParallaxProperties?: TVParallaxPropertiesType, /** * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. From ae91f74362d595082745a90184cf4c8199144907 Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Thu, 27 Sep 2018 15:19:50 -0400 Subject: [PATCH 07/10] UPDATE: TVViewPropTypes $ReadOnly --- Libraries/Components/AppleTV/TVViewPropTypes.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/Components/AppleTV/TVViewPropTypes.js b/Libraries/Components/AppleTV/TVViewPropTypes.js index 5acb26e52385..ce3651d5f490 100644 --- a/Libraries/Components/AppleTV/TVViewPropTypes.js +++ b/Libraries/Components/AppleTV/TVViewPropTypes.js @@ -10,7 +10,7 @@ 'use strict'; -type TVParallaxPropertiesType = { +type TVParallaxPropertiesType = $ReadOnly<{| /** * If true, parallax effects are enabled. Defaults to true. */ @@ -35,12 +35,12 @@ type TVParallaxPropertiesType = { * Defaults to 1.0 */ magnification: number, -}; +|}>; /** * Additional View properties for Apple TV */ -export type TVViewProps = { +export type TVViewProps = $ReadOnly<{| /** * *(Apple TV only)* When set to true, this view will be focusable * and navigable using the Apple TV remote. @@ -90,4 +90,4 @@ export type TVViewProps = { * @platform ios */ tvParallaxMagnification?: number, -}; +|}>; From 12d920975df527d026133658cf4ab794c0d73cb6 Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Thu, 4 Oct 2018 16:10:58 -0400 Subject: [PATCH 08/10] UPDATE: remove TimerMixin --- Libraries/Lists/ListView/ListView.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Libraries/Lists/ListView/ListView.js b/Libraries/Lists/ListView/ListView.js index b240620b1504..66a5c261f89e 100644 --- a/Libraries/Lists/ListView/ListView.js +++ b/Libraries/Lists/ListView/ListView.js @@ -18,7 +18,6 @@ const RCTScrollViewManager = require('NativeModules').ScrollViewManager; const ScrollView = require('ScrollView'); const ScrollResponder = require('ScrollResponder'); const StaticRenderer = require('StaticRenderer'); -const TimerMixin = require('react-timer-mixin'); const View = require('View'); const cloneReferencedElement = require('react-clone-referenced-element'); const createReactClass = require('create-react-class'); @@ -216,6 +215,7 @@ type Props = $ReadOnly<{| const ListView = createReactClass({ displayName: 'ListView', + _rafId: (null: ?AnimationFrameID), _childFrames: ([]: Array), _sentEndForContentLength: (null: ?number), _scrollComponent: (null: ?React.ElementRef), @@ -223,7 +223,7 @@ const ListView = createReactClass({ _visibleRows: ({}: Object), scrollProperties: ({}: Object), - mixins: [ScrollResponder.Mixin, TimerMixin], + mixins: [ScrollResponder.Mixin], statics: { DataSource: ListViewDataSource, @@ -347,16 +347,23 @@ const ListView = createReactClass({ contentLength: null, offset: 0, }; + this._childFrames = []; this._visibleRows = {}; this._prevRenderedRowsCount = 0; this._sentEndForContentLength = null; }, + componentWillUnmount: function() { + if (this._rafId != null) { + cancelAnimationFrame(this._rafId); + } + }, + componentDidMount: function() { // do this in animation frame until componentDidMount actually runs after // the component is laid out - this.requestAnimationFrame(() => { + this._rafId = requestAnimationFrame(() => { this._measureAndUpdateScrollProps(); }); }, @@ -384,7 +391,7 @@ const ListView = createReactClass({ }, componentDidUpdate: function() { - this.requestAnimationFrame(() => { + this._rafId = requestAnimationFrame(() => { this._measureAndUpdateScrollProps(); }); }, From cb2cc34a2bc17e20fe874e98ae4b8234755774a2 Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Sun, 4 Nov 2018 18:04:08 -0500 Subject: [PATCH 09/10] UPDATE: Flow strict mode --- Libraries/Text/TextProps.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Libraries/Text/TextProps.js b/Libraries/Text/TextProps.js index 773125d56be7..ff21b1ee95d6 100644 --- a/Libraries/Text/TextProps.js +++ b/Libraries/Text/TextProps.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -106,12 +106,12 @@ export type TextProps = $ReadOnly<{ * See https://facebook.github.io/react-native/docs/text.html#onpress */ onPress?: ?(event: PressEvent) => mixed, - onResponderGrant?: ?Function, - onResponderMove?: ?Function, - onResponderRelease?: ?Function, - onResponderTerminate?: ?Function, - onResponderTerminationRequest?: ?Function, - onStartShouldSetResponder?: ?Function, + onResponderGrant?: ?(event: SyntheticEvent<>, dispatchID: string) => void, + onResponderMove?: ?(event: SyntheticEvent<>) => void, + onResponderRelease?: ?(event: SyntheticEvent<>) => void, + onResponderTerminate?: ?(event: SyntheticEvent<>) => void, + onResponderTerminationRequest?: ?() => boolean, + onStartShouldSetResponder?: ?() => boolean, onTextLayout?: ?(event: TextLayoutEvent) => mixed, /** From caf011b9f5f264b96ef695b4ca74da8e2e311966 Mon Sep 17 00:00:00 2001 From: Thomas BARRAS Date: Tue, 6 Nov 2018 06:42:02 -0500 Subject: [PATCH 10/10] UPDATE: Replace SyntheticEvent types by PressEvent --- Libraries/Text/Text.js | 24 ++++++++++++------------ Libraries/Text/TextProps.js | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index f1b6c807874f..76d51ae9227d 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -27,10 +27,10 @@ import type {PressRetentionOffset, TextProps} from 'TextProps'; type ResponseHandlers = $ReadOnly<{| onStartShouldSetResponder: () => boolean, - onResponderGrant: (event: SyntheticEvent<>, dispatchID: string) => void, - onResponderMove: (event: SyntheticEvent<>) => void, - onResponderRelease: (event: SyntheticEvent<>) => void, - onResponderTerminate: (event: SyntheticEvent<>) => void, + onResponderGrant: (event: PressEvent, dispatchID: string) => void, + onResponderMove: (event: PressEvent) => void, + onResponderRelease: (event: PressEvent) => void, + onResponderTerminate: (event: PressEvent) => void, onResponderTerminationRequest: () => boolean, |}>; @@ -93,12 +93,12 @@ class TouchableText extends React.Component { touchableHandleLongPress: ?(event: PressEvent) => void; touchableHandlePress: ?(event: PressEvent) => void; touchableHandleResponderGrant: ?( - event: SyntheticEvent<>, + event: PressEvent, dispatchID: string, ) => void; - touchableHandleResponderMove: ?(event: SyntheticEvent<>) => void; - touchableHandleResponderRelease: ?(event: SyntheticEvent<>) => void; - touchableHandleResponderTerminate: ?(event: SyntheticEvent<>) => void; + touchableHandleResponderMove: ?(event: PressEvent) => void; + touchableHandleResponderRelease: ?(event: PressEvent) => void; + touchableHandleResponderTerminate: ?(event: PressEvent) => void; touchableHandleResponderTerminationRequest: ?() => boolean; state = { @@ -171,25 +171,25 @@ class TouchableText extends React.Component { } return shouldSetResponder; }, - onResponderGrant: (event: SyntheticEvent<>, dispatchID: string): void => { + onResponderGrant: (event: PressEvent, dispatchID: string): void => { nullthrows(this.touchableHandleResponderGrant)(event, dispatchID); if (this.props.onResponderGrant != null) { this.props.onResponderGrant.call(this, event, dispatchID); } }, - onResponderMove: (event: SyntheticEvent<>): void => { + onResponderMove: (event: PressEvent): void => { nullthrows(this.touchableHandleResponderMove)(event); if (this.props.onResponderMove != null) { this.props.onResponderMove.call(this, event); } }, - onResponderRelease: (event: SyntheticEvent<>): void => { + onResponderRelease: (event: PressEvent): void => { nullthrows(this.touchableHandleResponderRelease)(event); if (this.props.onResponderRelease != null) { this.props.onResponderRelease.call(this, event); } }, - onResponderTerminate: (event: SyntheticEvent<>): void => { + onResponderTerminate: (event: PressEvent): void => { nullthrows(this.touchableHandleResponderTerminate)(event); if (this.props.onResponderTerminate != null) { this.props.onResponderTerminate.call(this, event); diff --git a/Libraries/Text/TextProps.js b/Libraries/Text/TextProps.js index ff21b1ee95d6..878e42bef6fd 100644 --- a/Libraries/Text/TextProps.js +++ b/Libraries/Text/TextProps.js @@ -106,10 +106,10 @@ export type TextProps = $ReadOnly<{ * See https://facebook.github.io/react-native/docs/text.html#onpress */ onPress?: ?(event: PressEvent) => mixed, - onResponderGrant?: ?(event: SyntheticEvent<>, dispatchID: string) => void, - onResponderMove?: ?(event: SyntheticEvent<>) => void, - onResponderRelease?: ?(event: SyntheticEvent<>) => void, - onResponderTerminate?: ?(event: SyntheticEvent<>) => void, + onResponderGrant?: ?(event: PressEvent, dispatchID: string) => void, + onResponderMove?: ?(event: PressEvent) => void, + onResponderRelease?: ?(event: PressEvent) => void, + onResponderTerminate?: ?(event: PressEvent) => void, onResponderTerminationRequest?: ?() => boolean, onStartShouldSetResponder?: ?() => boolean, onTextLayout?: ?(event: TextLayoutEvent) => mixed,