test2 / client /src /components /Greeting.jsx
jaothan's picture
Upload 36 files
050d2e1 verified
raw
history blame contribute delete
412 Bytes
import { useEffect, useState } from 'react';
export function Greeting() {
const [greeting, setGreeting] = useState(null);
useEffect(() => {
fetch('/api/greeting')
.then((res) => res.json())
.then((data) => setGreeting(data.greeting));
}, [setGreeting]);
if (!greeting) return null;
return <h1 className="text-center mb-5">{greeting}</h1>;
}