mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
680abf2d56
Summary:
## Context
Moving SegmentedControlIOS to use a generated view config.
---
It's worth mentioning that even though `RCTSegmentedControlNativeComponent` defines a different event type to that of `RCTView`. We currently do not have 100% type safety for the event types in Paper. In other words, when an event for `onChange` in this case comes from the native side, it could potentially be shaped differently than what was typed in the native component file. This will be addressed in `Fabric`.
```
// RCTSegmentedControlNativeComponent.js
export type Event = $ReadOnly<{|
value: Int32,
selectedSegmentIndex: Int32,
|}>;
...
export type NativeProps = $ReadOnly<{|
...
onChange?: ?(event: BubblingEvent<Event>) => mixed,
|}>
```
This means that in the view config diff, there will be a value of `none` for `bubblingEventTypes`
Reviewed By: rickhanlonii
Differential Revision: D15851692
fbshipit-source-id: 6653fe7a77e46afdd55808aa5a4df813b34d7f70
39 lines
1016 B
JavaScript
39 lines
1016 B
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.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
'use strict';
|
|
|
|
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
|
|
import type {ViewProps} from '../View/ViewPropTypes';
|
|
import type {BubblingEvent, WithDefault, Int32} from '../../Types/CodegenTypes';
|
|
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
|
|
|
|
export type OnChangeEvent = BubblingEvent<
|
|
$ReadOnly<{|
|
|
value: Int32,
|
|
selectedSegmentIndex: Int32,
|
|
|}>,
|
|
>;
|
|
|
|
type NativeProps = $ReadOnly<{|
|
|
...ViewProps,
|
|
|
|
// Props
|
|
values?: $ReadOnlyArray<string>,
|
|
selectedIndex?: ?WithDefault<Int32, 0>,
|
|
enabled?: ?WithDefault<boolean, true>,
|
|
tintColor?: ?ColorValue,
|
|
momentary?: ?WithDefault<boolean, false>,
|
|
|
|
// Events
|
|
onChange?: ?(event: OnChangeEvent) => mixed,
|
|
|}>;
|
|
|
|
export default codegenNativeComponent<NativeProps>('RCTSegmentedControl');
|