Skip to content

Instantly share code, notes, and snippets.

@nedgrady
Created November 18, 2024 17:52
Show Gist options
  • Select an option

  • Save nedgrady/d22dbe0236447cbb6dad6d8ee27dfbeb to your computer and use it in GitHub Desktop.

Select an option

Save nedgrady/d22dbe0236447cbb6dad6d8ee27dfbeb to your computer and use it in GitHub Desktop.
function CommunicationList() {
const [communications, setCommunications] = useState<Communication[] | null>(
null
);
useEffect(() => {
fetch("/communications")
.then((res) => res.json())
.then(setCommunications);
}, []);
if (!communications) {
return <div>Loading...</div>;
}
return (
<ul>
{communications.map((communication) => (
<li key={communication.id}>{communication.name}</li>
))}
</ul>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment