import { useState, useEffect, useRef } from 'react'; import { useTranslation } from 'react-i18next'; import api from '../api'; import SEO from '../components/SEO'; import PluginCard from '../components/PluginCard'; const Home = () => { const { t } = useTranslation(); const [plugins, setPlugins] = useState([]); const hasFetched = useRef(false); useEffect(() => { if (hasFetched.current) return; api.get('/plugins', { params: { q: '', sort: 'newest' } }) .then(res => { setPlugins(Array.isArray(res.data) ? res.data : []); hasFetched.current = true; }) .catch(err => { console.error('Fetch error:', err); setPlugins([]); }); }, []); return ( <>

{t('welcome')}

Explore powerful plugins for your PumpkinMC experience.

{plugins.map((plugin) => ( ))} {plugins.length === 0 && (

No plugins found. Check back later!

)}
); }; export default Home;