From eacabe1398e29cee4d19c6d22905925ccbdf9620 Mon Sep 17 00:00:00 2001 From: Kacie Bawiec Date: Mon, 29 Mar 2021 15:21:43 -0700 Subject: [PATCH] Convert ScrollViewStickyHeader to functional component and gate the change Summary: Changelog: [Internal][Added] - Use injected ScrollViewStickyHeader if set Reviewed By: lunaleaps Differential Revision: D26931404 fbshipit-source-id: 6f6f1b501b610a05999898be3e2ce08aeb4dab1b --- .../ScrollView/ScrollViewStickyHeader.js | 8 +++++++- .../ScrollViewStickyHeaderInjection.js | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Libraries/Components/ScrollView/ScrollViewStickyHeaderInjection.js diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index da3f5037a90..a17d6350c65 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -20,6 +20,8 @@ import Platform from '../../Utilities/Platform'; import type {LayoutEvent} from '../../Types/CoreEventTypes'; +import ScrollViewStickyHeaderInjection from './ScrollViewStickyHeaderInjection'; + const AnimatedView = AnimatedImplementation.createAnimatedComponent(View); export type Props = $ReadOnly<{ @@ -328,4 +330,8 @@ const styles = StyleSheet.create({ }, }); -module.exports = ScrollViewStickyHeader; +const SHToExport: React.AbstractComponent< + Props, + $ReadOnly<{setNextHeaderY: number => void, ...}>, +> = ScrollViewStickyHeaderInjection.unstable_SH ?? ScrollViewStickyHeader; +module.exports = SHToExport; diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeaderInjection.js b/Libraries/Components/ScrollView/ScrollViewStickyHeaderInjection.js new file mode 100644 index 00000000000..ab8684ffb68 --- /dev/null +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeaderInjection.js @@ -0,0 +1,17 @@ +/** + * 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 + */ + +'use strict'; + +import typeof ScrollViewStickyHeader from './ScrollViewStickyHeader'; + +export default { + unstable_SH: (null: ?ScrollViewStickyHeader), +};