replace the "Loading..." text with an animated spinner: import React, { useState,…
- User
replace the "Loading..." text with an animated spinner:
import React, { useState, useEffect } from 'react'; import { PhoneIcon, MailIcon, LocationMarkerIcon } from '@heroicons/react/outline'; // Import Heroicons import profilePicture from '../assets/profile-picture.png'; import { fetchAcfData } from '../utils/api';
const Home = () => { const [acfData, setAcfData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null);
useEffect(() => { fetchAcfData('home') .then((data) => { setAcfData(data); }) .catch((err) => { setError(err.message); }) .finally(() => { setLoading(false); }); }, []);
if (loading) { return ( Loading... ); }
if (error) { return ( {error} ); }
if (!acfData) { return No data found for this page.; }
const { first_name, last_name, role, description, contact } = acfData;
return ( {first_name} {last_name} {role} {description} {contact && ( {/* Phone /} <a href={contact['phone_link']} className="fg-text-primary text-md" > {contact['phone_text']} {/ Email /} <a href={
mailto:${contact['email_link']}} className="fg-text-primary text-md" > {contact['email_text']} {/ Address */} <a href={contact['address_link']} className="fg-text-primary text-md" target="_blank" rel="noopener noreferrer" > {contact['address_text']} )} ); };export default Home;
- Assistant