Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flow-strict] Flow strict Slider #22127

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions Libraries/Components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @flow strict-local
*/

'use strict';
Expand All @@ -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<{|
/**
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 &&
Expand Down