sohobloo / react-native-modal-dropdown

A react-native dropdown/picker/selector component for both Android & iOS.
MIT License
1.19k stars 477 forks source link

dropdown/app freezes upon selection #162

Closed barron9 closed 6 years ago

barron9 commented 6 years ago

Hi

I am using this simple code, but dropdown freezes itself after i tap an option

<ModalDropdown options={['option 1', 'option 2']}
ref={ (ref) => this.lookaheadFilter = ref }
onSelect={ (idx, value) =>alert(idx) }
/>

if i use alert function or custom function it doesnt matter it stuck

wmfarooqi05 commented 6 years ago

This can be resolved by binding the calling function

barron9 commented 6 years ago

can you explain it within a code

wmfarooqi05 commented 6 years ago

This line was causing problem

onSelect={(idx, value) => this.onOptionSelect(idx, value)}

After binding it started working

onSelect={(idx, value) => this.onOptionSelect.bind(idx, value)}

barron9 commented 6 years ago

yes nice try but not working