Problem and Solutions
UseState() hook returns undefined when using option chained value as initial count in React js.
By M.K. Verma · 30 April 2022

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);