Preparing search index...

    Function useRecipes

    • Provides reactive recipe data and all recipe operations.

      The recipes array is a stable reference updated via useSyncExternalStore; React Compiler memoises derived values automatically, so no useMemo wrappers are needed in consumers.

      scalingProgress is local state — only the component calling scaleAllRecipesForNewDefaultPersons observes it; other consumers of this hook see undefined.

      decodeError is store-wide rather than slice-scoped: it reports corrupt data found while decoding any cached table. Recording one notifies the recipes slice, so the subscription above is what re-renders consumers when it appears.

      Returns {
          recipes: recipeTableElement[];
          decodeError: Error | null;
          scalingProgress: number | undefined;
          addRecipe: (recipe: RecipeDraft) => Promise<recipeTableElement>;
          editRecipe: (
              recipe: Omit<Draft<recipeTableElement>, "tags" | "ingredients"> & {
                  id?: number;
                  ingredients: IngredientDraft[];
                  tags: TagDraft[];
              } & { id: number },
          ) => Promise<recipeTableElement>;
          deleteRecipe: (recipe: recipeTableElement) => Promise<boolean>;
          findSimilarRecipes: (recipe: RecipeDraft) => recipeTableElement[];
          addMultipleRecipes: (recipesToAdd: RecipeDraft[]) => Promise<void>;
          scaleAllRecipesForNewDefaultPersons: (
              newDefaultPersons: number,
          ) => Promise<void>;
      }

      Object containing reactive recipes array, scalingProgress, decodeError (see RecipeDatabase.get_decode_error), and all recipe mutation functions