Fix useEffect hook for product fetching in CreateRecipePage component
This commit is contained in:
@@ -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<string | null>(null);
|
||||
|
||||
// Hämta produkter vid sidladdning
|
||||
useState(() => {
|
||||
useEffect(() => {
|
||||
fetchJson('/api/products')
|
||||
.then(setProducts)
|
||||
.catch(console.error);
|
||||
|
||||
Reference in New Issue
Block a user