react-native-material-dropdown icon indicating copy to clipboard operation
react-native-material-dropdown copied to clipboard

Feature request: Separator

Open gjvpaet opened this issue 8 years ago • 4 comments

It would be great if we can add an item separator in the picker dropdown items.

gjvpaet avatar Mar 01 '18 02:03 gjvpaet

@gjvpaet you can add separator using propsExtractor like this:

propsExtractor={({value, index}) => { return (value === 'lastElement' ? {style: {}} : {style: {borderBottomColor: '#D1D1D1', borderBottomWidth: 1, paddingTop: 5}}) }}

We will not add separator for last item.

tayyabaAslam avatar Apr 16 '19 12:04 tayyabaAslam

@gjvpaet you can add separator using propsExtractor like this:

propsExtractor={({value, index}) => { return (value === 'lastElement' ? {style: {}} : {style: {borderBottomColor: '#D1D1D1', borderBottomWidth: 1, paddingTop: 5}}) }}

We will not add separator for last item.

it doesn't work for me. Separator keeps showing in the last item.

Edit: it worked, I forgot to set the value of the last element.

IkaroAlef avatar Feb 17 '20 20:02 IkaroAlef

Great!

tayyabaAslam avatar Feb 18 '20 05:02 tayyabaAslam

Great!

but the "index" is returning undefine. It's working with "value" but I need to update this propsExtractor everytime I update de dropdown data or use with another dropdown (with different data, obviously.

Do you have any tip? . . . . Edit:

@gjvpaet you can add separator using propsExtractor like this:

propsExtractor={({value, index}) => { return (value === 'lastElement' ? {style: {}} : {style: {borderBottomColor: '#D1D1D1', borderBottomWidth: 1, paddingTop: 5}}) }}

We will not add separator for last item.

here's the solution: just remove {} inside de params and the index is returning correctly propsExtractor={(item, index) => { return index === <YOUR_DATA>.length - 1 ? { style: {}, // style for the last element } : { style: {}, //style for the others elements }; }}

IkaroAlef avatar Mar 10 '20 19:03 IkaroAlef