ESM ActivityIndicator

Summary: Changelog: [General][Changed] ActivityIndicator and remove .flow

Reviewed By: yungsters

Differential Revision: D42203449

fbshipit-source-id: 52ab1111166d23b7304e8406f299d23f9fd6f399
This commit is contained in:
Luna Wei 2023-01-03 18:09:06 -08:00 committed by Facebook GitHub Bot
parent 9af5c3330c
commit 9c57a7f209
5 changed files with 17 additions and 68 deletions

View File

@ -1,58 +0,0 @@
/**
* Copyright (c) Meta Platforms, Inc. and 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 type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {ViewProps} from '../View/ViewPropTypes';
import {type ColorValue} from '../../StyleSheet/StyleSheet';
import * as React from 'react';
type IndicatorSize = number | 'small' | 'large';
type IOSProps = $ReadOnly<{|
/**
Whether the indicator should hide when not animating.
@platform ios
*/
hidesWhenStopped?: ?boolean,
|}>;
type Props = $ReadOnly<{|
...ViewProps,
...IOSProps,
/**
Whether to show the indicator (`true`) or hide it (`false`).
*/
animating?: ?boolean,
/**
The foreground color of the spinner.
@default {@platform android} `null` (system accent default color)
@default {@platform ios} '#999999'
*/
color?: ?ColorValue,
/**
Size of the indicator.
@type enum(`'small'`, `'large'`)
@type {@platform android} number
*/
size?: ?IndicatorSize,
|}>;
export type ActivityIndicator = React.AbstractComponent<
Props,
HostComponent<mixed>,
>;

View File

@ -10,8 +10,8 @@
*/
'use strict';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {ViewProps} from '../View/ViewPropTypes';
import type {ActivityIndicator as ActivityIndicatorType} from './ActivityIndicator.flow';
import StyleSheet, {type ColorValue} from '../../StyleSheet/StyleSheet';
import Platform from '../../Utilities/Platform';
@ -184,8 +184,10 @@ const ActivityIndicator = (
```
*/
const ActivityIndicatorWithRef: ActivityIndicatorType =
React.forwardRef(ActivityIndicator);
const ActivityIndicatorWithRef: React.AbstractComponent<
Props,
HostComponent<mixed>,
> = React.forwardRef(ActivityIndicator);
ActivityIndicatorWithRef.displayName = 'ActivityIndicator';
const styles = StyleSheet.create({
@ -203,4 +205,4 @@ const styles = StyleSheet.create({
},
});
module.exports = ActivityIndicatorWithRef;
export default ActivityIndicatorWithRef;

View File

@ -11,9 +11,10 @@
'use strict';
import * as React from 'react';
const ReactNativeTestTools = require('../../../Utilities/ReactNativeTestTools');
const ActivityIndicator = require('../ActivityIndicator');
const React = require('react');
const ActivityIndicator = require('../ActivityIndicator').default;
describe('<ActivityIndicator />', () => {
it('should set displayName to prevent <Component /> regressions', () => {

View File

@ -108,7 +108,8 @@ module.exports = {
.default;
},
get ActivityIndicator(): ActivityIndicator {
return require('./Libraries/Components/ActivityIndicator/ActivityIndicator');
return require('./Libraries/Components/ActivityIndicator/ActivityIndicator')
.default;
},
get Button(): Button {
return require('./Libraries/Components/Button');

View File

@ -164,11 +164,14 @@ jest
const mockScrollView = jest.requireActual('./mockScrollView');
return mockScrollView(baseComponent);
})
.mock('../Libraries/Components/ActivityIndicator/ActivityIndicator', () =>
mockComponent(
.mock('../Libraries/Components/ActivityIndicator/ActivityIndicator', () => ({
__esModule: true,
default: mockComponent(
'../Libraries/Components/ActivityIndicator/ActivityIndicator',
null,
true,
),
)
}))
.mock('../Libraries/AppState/AppState', () => ({
addEventListener: jest.fn(() => ({
remove: jest.fn(),