Object containing ingredient manipulation functions
const { editIngredients, addNewIngredient, addOrMergeIngredient } = useRecipeIngredients();
// Add a new empty ingredient row
addNewIngredient();
// Edit an ingredient (triggers validation if name changes)
editIngredients(0, '200g flour');
// Add or merge a validated ingredient
addOrMergeIngredient({
id: 1,
name: 'flour',
quantity: '100',
unit: 'g',
season: [],
type: ''
});
React hook for managing ingredient operations in the Recipe screen.
This hook provides three main operations:
The hook handles the complexity of ingredient validation, fuzzy matching, and duplicate detection. When an ingredient name is changed, it uses the validation queue system to suggest similar ingredients from the database. For duplicate ingredients with matching units, quantities are automatically summed together.