import React, { useState, useEffect } from 'react'; import { Link } from 'react-router-dom'; const NewsSection = () => { const [news, setNews] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { // In a real app, this would fetch from an API // For demo purposes, we'll use mock data const mockNews = [ { id: 1, title: 'New Cold Chain Initiative Launched in Southeast Asia', excerpt: 'Regional partnership aims to reduce post-harvest losses by 30% through solar-powered refrigeration.', date: '2025-10-15', category: 'Policy' }, { id: 2, title: 'Innovative Edible Coatings Show Promise in Lab Trials', excerpt: 'New biodegradable coatings extend shelf life of fruits by up to 2 weeks.', date: '2025-10-10', category: 'Technology' }, { id: 3, title: 'Global Fund Announces $50M for FLW Reduction Projects', excerpt: 'Funding opportunity for pilot projects connecting smallholders to processing facilities.', date: '2025-10-05', category: 'Finance' } ]; setTimeout(() => { setNews(mockNews); setLoading(false); }, 500); }, []); if (loading) { return ( Latest News & Updates ); } if (error) { return ( Latest News & Updates Error loading news: {error} ); } return ( Latest News & Updates View All News → {news.map((item) => ( {item.category} {new Date(item.date).toLocaleDateString()} {item.title} {item.excerpt} Read More → ))} ); }; export default NewsSection;
Error loading news: {error}
{item.excerpt}