Skip to content

Conversation

@tvanlaerhoven
Copy link

Replace Slider's ViewStyle props with StyleProp<ViewStyle>.

This way the style props accept not only ViewStyle types, but also a (recursive) array of ViewStyle, and a Falsy type, which translates to false || null || undefined.

A user can then pass containerStyle, minimumTrackStyle, maximumTrackStyle, thumbStyle and trackStyle as:

  • array of styles: style={[styles.style1, styles.style2]}
  • any Falsy value, such as style={undefined}

which is not possible with bare ViewStyle.

It makes it easier for Slider users to optionally pass style overrides in their own CustomSlider:

const StyledSlider = ({ overrideContainerStyle }: { overrideContainerStyle?: StyleProp<ViewStyle> }) => {
  return (
    <Slider containerStyle={[styles.defaultSliderContainerStyle, overrideContainerStyle]} />
  );
};

The API remains backwards compatible with previous versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant