peacechen / react-native-modal-selector

A cross-platform (iOS / Android), selector/picker component for React Native that is highly customizable and supports sections.
MIT License
369 stars 129 forks source link

Added pass through props for Text components #92

Closed VacuumDecay closed 5 years ago

VacuumDecay commented 5 years ago

Added optionTextPassThruProps and selectTextPassThruProps to allow users to pass props to Text components

peacechen commented 5 years ago

Thanks @VacuumDecay for the PR. Have you tested this change? It looks like this line will cause an error: https://github.com/peacechen/react-native-modal-selector/pull/92/commits/b670be22734333bd5ab6c5c1373ee7768314abc2#diff-168726dbe96b3ce427e7fedce31bb0bcR196

<Text style={[styles.optionTextStyle,this.props.optionTextStyle,isSelectedItem && this.props.selectedItemTextStyle]} {...this.props.optionTextPassThruProps}>

The pass thru props should be inside the array passed to style.

VacuumDecay commented 5 years ago

@peacechen Thanks for taking a look at this. Perhaps I have misunderstood something but I'm not passing any styles to the to the Text component. I tried passing props ellipsizeMode and 'numberOfLines' like so:

<ModalSelector
       data={data}
       initValue="Pick an option"
       optionTextPassThruProps={{numberOfLines: 1  }}
       selectTextPassThruProps={{numberOfLines: 1, ellipsizeMode: 'head' }} />

This worked in my test

peacechen commented 5 years ago

Yes you're right. I mistakenly thought this was for the styling.

Would you update the Readme with these new props?

VacuumDecay commented 5 years ago

No problem. Readme has been updated

peacechen commented 5 years ago

Thanks for the quick turn-around 👍