import React from 'react'; export function Twitter() { const [tweets, setTweets] = React.useState(); const [error, setError] = React.useState(); React.useEffect(() => { fetch('/api/twitter') .then((res) => res.json()) .then((res) => { if (res.error) { throw Error(res.error); } setTweets(res.data.statuses); }) .catch((err) => { setError(true); }); }, []); return ( <>
{!error && !tweets && (
)} {error && (
The twitter overlords can't seem to find any tweets right now. Maybe our API limits are up. Check back later. Or view it on Twitter{' '} here .
)} {tweets && tweets.length > 0 && ( )}
); }