Files
react-native/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js
T
Rick Hanlon efec97f2be Add view config babel plugin
Summary:
This diff adds a babel plugin for the generated view configs which will inline them in the file instead of needing to check the view configs in (fb only)

The way it works is:
- babel reads the code
- looks for type alias `CodegenNativeComponent` in `*NativeComponet.js` files
- run the flow parser on the file source to create a schema
- run the schema into codegen to get the view config source code
- inject the generated source code back into the NativeComponent.js file
- remove the original export
- profit

After this diff we will remove the `js1 build viewconfigs` command and the checked-in NativeViewConfig.js files

Note: since this plugin is not published to open source, for now OSS will continue using the `requireNativeComponent` function

Reviewed By: cpojer

Differential Revision: D15516062

fbshipit-source-id: a8efb077773e04fd9753a7036682eeaae9175e09
2019-06-07 12:31:36 -07:00

54 lines
1.4 KiB
JavaScript

/**
* 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 type {BubblingEvent, WithDefault} from '../../Types/CodegenTypes';
import type {NativeComponent} from '../../Renderer/shims/ReactNative';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ViewProps} from '../View/ViewPropTypes';
const requireNativeComponent = require('../../ReactNative/requireNativeComponent');
type NativeProps = $ReadOnly<{|
...ViewProps,
/**
* The color of the refresh indicator.
*/
tintColor?: ?ColorValue,
/**
* Title color.
*/
titleColor?: ?ColorValue,
/**
* The title displayed under the refresh indicator.
*/
title?: ?WithDefault<string, ''>,
/**
* Called when the view starts refreshing.
*/
onRefresh?: ?(event: BubblingEvent<null>) => mixed,
/**
* Whether the view should be indicating an active refresh.
*/
refreshing: WithDefault<boolean, false>,
|}>;
// TODO: Switch this over to CodegenNativeComponent
// once the native components are renamed in paper and fabric
type PullToRefreshViewType = Class<NativeComponent<NativeProps>>;
module.exports = ((requireNativeComponent(
'RCTRefreshControl',
): any): PullToRefreshViewType);