Files
react-native/Libraries/Components/Slider/SliderNativeComponent.js
T
Rick Hanlon 504fc0c7d0 Update flow parser to use codegenNativeComponent
Summary:
This diff updated the codegen flow types syntax replacing:

```
type Options = {
  isDeprecatedPaperComponentNameRCT: true,
};

type ActivityIndicatorNativeType = CodegenNativeComponent<
  'ActivityIndicatorView',
  NativeProps,
  Options,
>;

module.exports = ((requireNativeComponent(
  'RCTActivityIndicatorView',
): any): ActivityIndicatorNativeType);
```
with:

```
export default codegenNativeComponent<NativeProps>('ActivityIndicatorView', {
  isDeprecatedPaperComponentNameRCT: true,
});
```

This is from Tim's comment in the [View Config Codegen Quip](https://fb.quip.com/jR2aASHad4Se):

> What it CodegenNativeComponent were instead `NativeComponent.fromFlow<T>('…')` that returned `'...'`?
>And the Babel plugin swapped it for NativeComponent.fromSchema('...', {…}) which would both register and return '...'?

I went with `codegenNativeComponent` because it has nice parity with `requireNativeComponent`

I also didn't update the babel output here (we can update that whenever) because I think `registerGeneratedViewConfig` is more clear for what it's doing

Reviewed By: cpojer

Differential Revision: D15602077

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

60 lines
1.5 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 {
Float,
BubblingEvent,
DirectEvent,
WithDefault,
} from '../../Types/CodegenTypes';
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {ImageSource} from '../../Image/ImageSource';
import type {ViewProps} from '../View/ViewPropTypes';
type Event = $ReadOnly<{|
value: Float,
fromUser?: boolean,
|}>;
type NativeProps = $ReadOnly<{|
...ViewProps,
// Props
disabled?: ?WithDefault<boolean, false>,
enabled?: ?WithDefault<boolean, false>,
maximumTrackImage?: ?ImageSource,
maximumTrackTintColor?: ?ColorValue,
maximumValue?: ?WithDefault<Float, 1>,
minimumTrackImage?: ?ImageSource,
minimumTrackTintColor?: ?ColorValue,
minimumValue?: ?WithDefault<Float, 0>,
step?: ?WithDefault<Float, 0>,
testID?: ?WithDefault<string, ''>,
thumbImage?: ?ImageSource,
thumbTintColor?: ?ColorValue,
trackImage?: ?ImageSource,
value: ?WithDefault<Float, 0>,
// Events
onChange?: ?(event: BubblingEvent<Event>) => void,
onValueChange?: ?(event: BubblingEvent<Event>) => void,
onSlidingComplete?: ?(event: DirectEvent<Event>) => void,
|}>;
module.exports = codegenNativeComponent<NativeProps>('Slider', {
interfaceOnly: true,
isDeprecatedPaperComponentNameRCT: true,
});