So i got a setState
named items
const [items, setItems] = React.useState([]);
My Items Array Structure
[{
"id": "0.625240011345925",
"item_name": "Item 23",
"item_price": "23",
"item_qty": "1"
}, {
"id": "0.735657461482515",
"item_name": "Item 4",
"item_price": "30",
"item_qty": "1"
}, {
"id": "0.287635530963835",
"item_name": "Item 2",
"item_price": "56",
"item_qty": "1"
}]
Main Function
const AddItemToBill = (navigation) => {
navigation.navigate('AddItemToBill', {
onReturn: (itemArray) => {
const array = itemArray;
for (let i = 0; i < array.length; i++) {
const element = array[i];
setItems([...items, element]);
console.log('Items: ' + JSON.stringify(array))
}
}, navigation
})
};
Check issue in below Gif