Skip to content

Commit

Permalink
Slider remove $FlowFixMe #take2
Browse files Browse the repository at this point in the history
Reviewed By: fkgozali

Differential Revision: D8246336

fbshipit-source-id: 21555a318bd823309ac2c285b49c2045338c2b28
  • Loading branch information
elicwhite authored and facebook-github-bot committed Jun 2, 2018
1 parent 7498e5c commit 1615f9d
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions Libraries/Components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,44 +249,38 @@ const Slider = createReactClass({
},

render: function() {
const {style, onValueChange, onSlidingComplete, ...props} = this.props;
/* $FlowFixMe(>=0.54.0 site=react_native_fb,react_native_oss) This comment
* suppresses an error found when Flow v0.54 was deployed. To see the error
* delete this comment and run Flow. */
props.style = [styles.slider, style];

/* $FlowFixMe(>=0.54.0 site=react_native_fb,react_native_oss) This comment
* suppresses an error found when Flow v0.54 was deployed. To see the error
* delete this comment and run Flow. */
props.onValueChange =
onValueChange &&
const style = StyleSheet.compose(styles.slider, this.props.style);

const onValueChange =
this.props.onValueChange &&
((event: Event) => {
let userEvent = true;
if (Platform.OS === 'android') {
// On Android there's a special flag telling us the user is
// dragging the slider.
userEvent = event.nativeEvent.fromUser;
}
onValueChange && userEvent && onValueChange(event.nativeEvent.value);
this.props.onValueChange &&
userEvent &&
this.props.onValueChange(event.nativeEvent.value);
});

/* $FlowFixMe(>=0.54.0 site=react_native_fb,react_native_oss) This comment
* suppresses an error found when Flow v0.54 was deployed. To see the error
* delete this comment and run Flow. */
props.onChange = props.onValueChange;
const onChange = onValueChange;

/* $FlowFixMe(>=0.54.0 site=react_native_fb,react_native_oss) This comment
* suppresses an error found when Flow v0.54 was deployed. To see the error
* delete this comment and run Flow. */
props.onSlidingComplete =
onSlidingComplete &&
const onSlidingComplete =
this.props.onSlidingComplete &&
((event: Event) => {
onSlidingComplete && onSlidingComplete(event.nativeEvent.value);
this.props.onSlidingComplete &&
this.props.onSlidingComplete(event.nativeEvent.value);
});

return (
<RCTSlider
{...props}
{...this.props}
style={style}
onChange={onChange}
onSlidingComplete={onSlidingComplete}
onValueChange={onValueChange}
enabled={!this.props.disabled}
onStartShouldSetResponder={() => true}
onResponderTerminationRequest={() => false}
Expand Down

0 comments on commit 1615f9d

Please sign in to comment.