From fd08255b0bc45eb9db7d157f3eb0a0106ca399a4 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Thu, 1 Jul 2021 14:33:45 -0700 Subject: [PATCH] Refactor SectionListExample Summary: Changelog: [Internal] - Refactor SectionListExample Reviewed By: kacieb Differential Revision: D29480050 fbshipit-source-id: edaa21e12d4be0fbe3d6cf147c74b8144eb7c3de --- ...stExample.js => SectionList-scrollable.js} | 22 ++++++++----------- .../examples/SectionList/SectionListIndex.js | 19 ++++++++++++++++ .../js/utils/RNTesterList.android.js | 2 +- .../rn-tester/js/utils/RNTesterList.ios.js | 2 +- 4 files changed, 30 insertions(+), 15 deletions(-) rename packages/rn-tester/js/examples/SectionList/{SectionListExample.js => SectionList-scrollable.js} (94%) create mode 100644 packages/rn-tester/js/examples/SectionList/SectionListIndex.js diff --git a/packages/rn-tester/js/examples/SectionList/SectionListExample.js b/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js similarity index 94% rename from packages/rn-tester/js/examples/SectionList/SectionListExample.js rename to packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js index ac9c8392310..78c28ae4f02 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionListExample.js +++ b/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js @@ -146,7 +146,9 @@ const onScrollToIndexFailed = (info: { */ }; -function SectionListExample(Props: {...}): React.Element { +export function SectionList_scrollable(Props: { + ..., +}): React.Element { const scrollPos = new Animated.Value(0); const scrollSinkY = Animated.event( [{nativeEvent: {contentOffset: {y: scrollPos}}}], @@ -338,16 +340,10 @@ const styles = StyleSheet.create({ }, }); -exports.title = 'SectionList'; -exports.category = 'ListView'; -exports.documentationURL = 'https://reactnative.dev/docs/sectionlist'; -exports.description = 'Performant, scrollable list of data.'; -exports.showIndividualExamples = true; -exports.examples = [ - { - title: 'Simple scrollable list', - render: function(): React.Element { - return ; - }, +export default { + title: 'SectionList scrollable', + name: 'SectionList-scrollable', + render: function(): React.Element { + return ; }, -]; +}; diff --git a/packages/rn-tester/js/examples/SectionList/SectionListIndex.js b/packages/rn-tester/js/examples/SectionList/SectionListIndex.js new file mode 100644 index 00000000000..743865b1f3e --- /dev/null +++ b/packages/rn-tester/js/examples/SectionList/SectionListIndex.js @@ -0,0 +1,19 @@ +/** + * 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 SectionList_Scrollable from './SectionList-scrollable'; + +exports.title = 'SectionList'; +exports.category = 'ListView'; +exports.documentationURL = 'https://reactnative.dev/docs/sectionlist'; +exports.description = 'Performant, scrollable list of data.'; +exports.examples = [SectionList_Scrollable]; diff --git a/packages/rn-tester/js/utils/RNTesterList.android.js b/packages/rn-tester/js/utils/RNTesterList.android.js index f3a58071057..43ba938335d 100644 --- a/packages/rn-tester/js/utils/RNTesterList.android.js +++ b/packages/rn-tester/js/utils/RNTesterList.android.js @@ -122,7 +122,7 @@ const Components: Array = [ { key: 'SectionListExample', category: 'ListView', - module: require('../examples/SectionList/SectionListExample'), + module: require('../examples/SectionList/SectionListIndex'), }, { key: 'StatusBarExample', diff --git a/packages/rn-tester/js/utils/RNTesterList.ios.js b/packages/rn-tester/js/utils/RNTesterList.ios.js index 2292288ee01..cb7221a1222 100644 --- a/packages/rn-tester/js/utils/RNTesterList.ios.js +++ b/packages/rn-tester/js/utils/RNTesterList.ios.js @@ -145,7 +145,7 @@ const Components: Array = [ }, { key: 'SectionListExample', - module: require('../examples/SectionList/SectionListExample'), + module: require('../examples/SectionList/SectionListIndex'), category: 'ListView', supportsTVOS: true, },