Flow strict Slider (#22127)
Summary: Related to #22100 Turn on Flow strict mode for Slider. Enhanced event type and props callbacks type defs for Slider. - All flow tests succeed. [GENERAL] [ENHANCEMENT] [Slider.js] - Flow strict mode Pull Request resolved: https://github.com/facebook/react-native/pull/22127 Differential Revision: D12946817 Pulled By: TheSavior fbshipit-source-id: 631391f70c04fddf0bfa6fec92f5cb769a555547
This commit is contained in:
parent
1d62e94b85
commit
c03fc4087f
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
@ -21,10 +21,19 @@ import type {ImageSource} from 'ImageSource';
|
|||
import type {ViewStyleProp} from 'StyleSheet';
|
||||
import type {ColorValue} from 'StyleSheetTypes';
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
import type {SyntheticEvent} from 'CoreEventTypes';
|
||||
|
||||
const RCTSlider = requireNativeComponent('RCTSlider');
|
||||
|
||||
type Event = Object;
|
||||
type Event = SyntheticEvent<
|
||||
$ReadOnly<{|
|
||||
value: number,
|
||||
/**
|
||||
* Android Only.
|
||||
*/
|
||||
fromUser?: boolean,
|
||||
|}>,
|
||||
>;
|
||||
|
||||
type IOSProps = $ReadOnly<{|
|
||||
/**
|
||||
|
@ -118,14 +127,14 @@ type Props = $ReadOnly<{|
|
|||
/**
|
||||
* Callback continuously called while the user is dragging the slider.
|
||||
*/
|
||||
onValueChange?: ?Function,
|
||||
onValueChange?: ?(value: number) => void,
|
||||
|
||||
/**
|
||||
* Callback that is called when the user releases the slider,
|
||||
* regardless if the value has changed. The current value is passed
|
||||
* as an argument to the callback handler.
|
||||
*/
|
||||
onSlidingComplete?: ?Function,
|
||||
onSlidingComplete?: ?(value: number) => void,
|
||||
|
||||
/**
|
||||
* Used to locate this view in UI automation tests.
|
||||
|
@ -209,7 +218,8 @@ const Slider = (
|
|||
if (Platform.OS === 'android') {
|
||||
// On Android there's a special flag telling us the user is
|
||||
// dragging the slider.
|
||||
userEvent = event.nativeEvent.fromUser;
|
||||
userEvent =
|
||||
event.nativeEvent.fromUser != null && event.nativeEvent.fromUser;
|
||||
}
|
||||
props.onValueChange &&
|
||||
userEvent &&
|
||||
|
|
Loading…
Reference in New Issue