Answer. maybe your find method return undefined because state is undefined
const get = (data) => {
const inventoryId = 8;
const selectedInventory = data.find(
inventory => inventory.id === inventoryId
);
return selectedInventory;
}
const totalQuantity = get([{id: 4,quantity:888 }, {id: 8, quantity:88 }, {id: 9, quantity:787}]);
const [carQuantity, setCarQuantity] = React.useState(totalQuantity);
console.log(carQuantity);
* Be the first to Make Comment