JackDanielsAndCode / react-native-multi-slider

Pure JS react native slider component with one or two markers.
MIT License
151 stars 96 forks source link

added possibility to add customProps to customMarker #24

Closed Mbompr closed 8 years ago

Mbompr commented 8 years ago

My customMarker is a React component and I needed to pass props to it. Hence, I added a new prop customProps to do it.

mrlaessig commented 8 years ago

Have you tried to wrap your custom marker to pass props to it?

const CustomMarker = props => {
  const { markerStyle, pressed, pressedMarkerStyle, text } = props;
  return (
    <View style={[ markerStyle, pressed && pressedMarkerStyle ]}>
      {text && <Text>{text}</Text>}
    </View>
  );
}

// ...

<Slider values={[1]} min={0} max={10} customMarker={props =>
    <CustomMarker {...props} text="Custom Marker" />
  }
/>

// ...

Edit: Feel free to reopen if this doesn't serve your needs

Mbompr commented 8 years ago

It worked like a charm, thanks!