mirror of
https://github.com/facebook/react-native.git
synced 2024-11-21 22:10:14 +00:00
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:
parent
9af5c3330c
commit
9c57a7f209
@ -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>,
|
||||
>;
|
@ -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;
|
||||
|
@ -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', () => {
|
||||
|
3
index.js
3
index.js
@ -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');
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user