I'm trying to code a method that show recursively an ActionSheetIOS to select a value contained from arrays and return the selected values:
async function _rescursiveSelect(data, index) {
if (index < data.length) {
const object = data[index];
if (object.array.length === 1) {
return await _rescursiveSelect(data, index + 1);
}
ActionSheetIOS.showActionSheetWithOptions({
title: 'Choose a value from array: ',
options: object.array,
},
buttonIndex => async function() {
const selectedValue = data[index].array[buttonIndex];
data[index].value = selectedValue;
delete data[index].array;
return await _rescursiveSelect(data, index + 1);
});
} else {
return data;
}
}
Unfortunately, when I call this method, it returns undefined
. I guess the problem comes from async/await using but I didn't fount it yet.
Any suggestion?