Preparing search index...
    • useRecipeDatabase - React hook for accessing reactive database state and operations

      Provides access to reactive database state and all database operations. Components using this hook will automatically re-render when database state changes.

      Must be used within a RecipeDatabaseProvider component tree.

      Returns RecipeDatabaseContextType

      RecipeDatabaseContextType object containing:

      • Reactive state: recipes, ingredients, tags, shopping (direct state access)
      • CRUD operations: add*, edit*, delete* for recipes/ingredients/tags
      • Shopping operations: addRecipeToShopping, purchaseIngredientInShoppingList, clearShoppingList
      • Utility functions: findSimilar*, getRandom*, scaleAllRecipesForNewDefaultPersons

      Error if used outside RecipeDatabaseProvider

      function RecipeList() {
      const { recipes, addRecipe, deleteRecipe } = useRecipeDatabase();

      // Component automatically re-renders when recipes state changes
      return (
      <FlatList
      data={recipes}
      renderItem={({item}) => <RecipeCard recipe={item} />}
      />
      );
      }
      function AddRecipeButton() {
      const { addRecipe } = useRecipeDatabase();

      const handleAdd = async () => {
      await addRecipe(newRecipe);
      // All components using useRecipeDatabase will automatically update
      };

      return <Button onPress={handleAdd}>Add Recipe</Button>;
      }