Closed CarlosJJR closed 6 years ago
the problem seems to be in the function _itemSelected
_itemSelected = item => { const { uniqueKey, selectedItems } = this.props; return !!find(selectedItems, singleItem => item[uniqueKey] === singleItem); };
Replacing the lodash function find
seems to fix the issue:
_itemSelected = item => { const { uniqueKey, selectedItems } = this.props; return selectedItems.indexOf(item[uniqueKey]) !== -1; };
Issue summary
When you select the first item of the array it isn't marked as selected and is added multiple times to 'selectedItems'
Library versions
react-native: 0.48.0 react-native-multiple-select: ^0.2.7
Steps to Reproduce
Expected Behavior
The first option should be selected or unselected according with selectedItems
Actual Behavior
The first option is never marked as selected and index 0 is added multiple times to selectedItems
Item 0 is selected when the list is collapsed
But when the list is shown, the item is nor marked as selected
After clicking multiple times the first item it is repeated on selectedItems