Files

@codebaseuseProducts.js
useProducts.js
import { useState, useEffect } from 'react'; export function useProducts() { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { fetch('/api/products') .then(res => res.json()) .then(setData) .catch(setError) .finally(() => setLoading(false)); }, []); return { data, loading, error }; }

Add TypeScript types to this hook. Define a Product interface with: - id: number - name: string - price: number - description: string - inStock: boolean

ChatClaude 3.7 SonnetThinking