Fix useEffect hook for product fetching in CreateRecipePage component

This commit is contained in:
Nils-Johan Gynther
2026-04-09 22:58:49 +02:00
parent 898ac2ef19
commit 69393f407c
@@ -1,6 +1,6 @@
'use client'; 'use client';
import { useState } from 'react'; import { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import { fetchJson } from '../../../lib/api'; import { fetchJson } from '../../../lib/api';
@@ -16,8 +16,7 @@ export default function CreateRecipePage() {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
// Hämta produkter vid sidladdning useEffect(() => {
useState(() => {
fetchJson('/api/products') fetchJson('/api/products')
.then(setProducts) .then(setProducts)
.catch(console.error); .catch(console.error);