I am using flatlist with checkboxes and I want to save the data of selected item into an array but can't be able to save the data in array
my json response
{
"tS_CT_CODE": "ELC",
"tS_TASK_CODE": "ELC001",
"tS_TITLE": "Light Problem",
"tS_TITLE_AR": "",
"tS_PRICE": 100.0,
"tS_STATUS": "A",
"tS_USER_ID": "",
"tS_SYSTEM_DATE": ""
}
I want to save tsPrice in different array and tsTitle in different array I am just able to do save only ts_title in taskName as you can see below how can I save ts_price in different array?
here is my CheckBox
const [toggleCheckBox, setToggleCheckBox] = useState([]);
<CheckBox
checked={toggleCheckBox.includes(item.tS_TITLE)}
onPress={() => handleListTap(item)}
/>
const handleListTap = async item => {
const taskName = [...toggleCheckBox];
const index = taskName.indexOf(item.tS_TITLE);
if (index > -1) {
taskName.splice(index, 1);
} else {
taskName.push(item.tS_TITLE);
}
console.log(taskName);
setToggleCheckBox(taskName);
// navigation.navigate('MaintenanceTimeSlot');
};
Aucun commentaire:
Enregistrer un commentaire