From 69393f407c2ca973c7efe988432e9174016ac240 Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Thu, 9 Apr 2026 22:58:49 +0200 Subject: [PATCH] Fix useEffect hook for product fetching in CreateRecipePage component --- frontend/app/recipes/create/CreateRecipePage.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/app/recipes/create/CreateRecipePage.tsx b/frontend/app/recipes/create/CreateRecipePage.tsx index b14bb968..30bacebe 100644 --- a/frontend/app/recipes/create/CreateRecipePage.tsx +++ b/frontend/app/recipes/create/CreateRecipePage.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import { fetchJson } from '../../../lib/api'; @@ -16,8 +16,7 @@ export default function CreateRecipePage() { const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); - // Hämta produkter vid sidladdning - useState(() => { + useEffect(() => { fetchJson('/api/products') .then(setProducts) .catch(console.error);