From 6958bbb28c0f735db6026f3500df2fbbf58e697f Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Fri, 22 Apr 2022 16:25:25 -0700 Subject: [PATCH] Fix up lint errors under react-native-github (#33622) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/33622 Changelog: [Internal] Clean up eslint errors Reviewed By: yungsters Differential Revision: D35599445 fbshipit-source-id: bbb9061a3cf9df32daacad9a9b44eba94d3ce48c --- Libraries/Lists/VirtualizedSectionList.js | 1 + .../NativeComponentRegistry.js | 2 - .../js/components/RNTesterModuleList.js | 1 + .../examples/Appearance/AppearanceExample.js | 127 ++-- .../examples/Dimensions/DimensionsExample.js | 9 +- .../examples/ScrollView/ScrollViewExample.js | 327 +++++----- .../SectionList/SectionList-scrollable.js | 2 + .../js/examples/Timer/TimerExample.js | 91 ++- .../rn-tester/js/examples/View/ViewExample.js | 561 +++++++++--------- scripts/bump-oss-version.js | 15 +- scripts/prepare-package-for-release.js | 1 - 11 files changed, 558 insertions(+), 579 deletions(-) diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 8c031d54975..3420e17d926 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -338,6 +338,7 @@ class VirtualizedSectionList< _renderItem = (listItemCount: number) => + // eslint-disable-next-line react/no-unstable-nested-components ({item, index}: {item: Item, index: number, ...}) => { const info = this._subExtractor(index); if (!info) { diff --git a/Libraries/NativeComponent/NativeComponentRegistry.js b/Libraries/NativeComponent/NativeComponentRegistry.js index e56021877f0..bcddcdaf6c8 100644 --- a/Libraries/NativeComponent/NativeComponentRegistry.js +++ b/Libraries/NativeComponent/NativeComponentRegistry.js @@ -23,8 +23,6 @@ import * as React from 'react'; let getRuntimeConfig; -let componentNameToExists: Map = new Map(); - /** * Configures a function that is called to determine whether a given component * should be registered using reflection of the native component at runtime. diff --git a/packages/rn-tester/js/components/RNTesterModuleList.js b/packages/rn-tester/js/components/RNTesterModuleList.js index e7e6b2fc0f9..0ccbe6216fd 100644 --- a/packages/rn-tester/js/components/RNTesterModuleList.js +++ b/packages/rn-tester/js/components/RNTesterModuleList.js @@ -153,6 +153,7 @@ const RNTesterModuleList: React$AbstractComponent = React.memo( automaticallyAdjustContentInsets={false} keyboardDismissMode="on-drag" renderSectionHeader={renderSectionHeader} + // eslint-disable-next-line react/no-unstable-nested-components ListFooterComponent={() => } /> )} diff --git a/packages/rn-tester/js/examples/Appearance/AppearanceExample.js b/packages/rn-tester/js/examples/Appearance/AppearanceExample.js index 8c7e97588a2..d19d8a5832f 100644 --- a/packages/rn-tester/js/examples/Appearance/AppearanceExample.js +++ b/packages/rn-tester/js/examples/Appearance/AppearanceExample.js @@ -77,6 +77,70 @@ const ThemedText = props => ( ); +const AppearanceViaHook = () => { + const colorScheme = useColorScheme(); + return ( + + + useColorScheme(): {colorScheme} + + + ); +}; + +const ColorShowcase = props => ( + + {theme => { + return ( + + + {props.themeName} + + {Object.keys(theme).map(key => ( + + + + + {key} + + + {typeof theme[key] === 'string' + ? theme[key] + : JSON.stringify(theme[key])} + + + + ))} + + ); + }} + +); + exports.title = 'Appearance'; exports.category = 'UI'; exports.documentationURL = 'https://reactnative.dev/docs/appearance'; @@ -85,17 +149,6 @@ exports.examples = [ { title: 'useColorScheme hook', render(): React.Node { - const AppearanceViaHook = () => { - const colorScheme = useColorScheme(); - return ( - - - useColorScheme(): {colorScheme} - - - ); - }; return ; }, }, @@ -155,58 +208,6 @@ exports.examples = [ title: 'RNTester App Colors', description: 'A light and a dark theme based on standard iOS 13 colors.', render(): React.Element { - const ColorShowcase = props => ( - - {theme => { - return ( - - - {props.themeName} - - {Object.keys(theme).map(key => ( - - - - - {key} - - - {typeof theme[key] === 'string' - ? theme[key] - : JSON.stringify(theme[key])} - - - - ))} - - ); - }} - - ); - return ( diff --git a/packages/rn-tester/js/examples/Dimensions/DimensionsExample.js b/packages/rn-tester/js/examples/Dimensions/DimensionsExample.js index 8aeae21e86e..e8b8554b2aa 100644 --- a/packages/rn-tester/js/examples/Dimensions/DimensionsExample.js +++ b/packages/rn-tester/js/examples/Dimensions/DimensionsExample.js @@ -42,6 +42,11 @@ class DimensionsSubscription extends React.Component< } } +const DimensionsViaHook = () => { + const dims = useWindowDimensions(); + return {JSON.stringify(dims, null, 2)}; +}; + exports.title = 'Dimensions'; exports.category = 'UI'; exports.documentationURL = 'https://reactnative.dev/docs/dimensions'; @@ -50,10 +55,6 @@ exports.examples = [ { title: 'useWindowDimensions hook', render(): React.Node { - const DimensionsViaHook = () => { - const dims = useWindowDimensions(); - return {JSON.stringify(dims, null, 2)}; - }; return ; }, }, diff --git a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js index 27934da4b0b..b16cd20d5bf 100644 --- a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js +++ b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js @@ -28,6 +28,166 @@ import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; import ScrollViewPressableStickyHeaderExample from './ScrollViewPressableStickyHeaderExample'; +class EnableDisableList extends React.Component<{}, {scrollEnabled: boolean}> { + state = { + scrollEnabled: true, + }; + render() { + return ( + + + {ITEMS.map(createItemRow)} + + + {'Scrolling enabled = ' + this.state.scrollEnabled.toString()} + +