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.filter((tweet) => tweet.favorite_count > 5) ); }) .catch((err) => { setError(true); }); }, []); if (!tweets || !(tweets.length > 5)) { return null; } return (

What are people saying?

{!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 && ( )}
); }