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

Feature/styleprop #462

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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