I'm using a multiple selection list to React Native. It is react-native-sectioned-multi-select.
I used it to input data to form. When inserting data using the selection list, it works fine. No problem. Now, I need to edit form. So, when I load the form, it does not load selected items to the selection list. I used onSelectedItemsChange to load data. But, I'm getting an error. Instead of automatically calling that function, if I call the function using a button, it loads selected items. But, I need to do it without manually clicking a button.
Here is my code regarding the multiple select.
<SectionedMultiSelect
items={this.state.items}
uniqueKey="id"
subKey="subItem"
selectText="Select"
confirmText="Select"
searchPlaceholderText="Search"
removeAllText="Clear all"
showDropDowns={true}
readOnlyHeadings={true}
showCancelButton={true}
showRemoveAll={true}
onSelectedItemsChange={this.onSelectedItemsChange}
selectedItems={this.state.selectedItems}
onSelectedItemsChange = (selectedItems) => {
this.setState({ selectedItems});
};
When I try to automatically setState of selectedItems it gives the error. But, if I set the state of selectedItems by a button press, it works and selected items are displayed.
Can anyone help me in this case?
https://github.com/renrizzolo/react-native-sectioned-multi-select
onSelectedItemsChange