mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
working typescript version
This commit is contained in:
1 parent
581d6011e0
commit
cff746aa38
119 files changed
+247
-189
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
import { List } from "../../../../ui/components/List";
|
||||
import Tweet from "./Tweet";
|
||||
import TweetSkeletonList from "./TweetSkeletonList";
|
||||
|
||||
const MINIMUM_LOAD_TIME = 700;
|
||||
|
||||
export function TweetList({ tweets }) {
|
||||
const [minimumLoadPassed, setMimimumLoadPassed] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const timeout = window.setTimeout(() => {
|
||||
setMimimumLoadPassed(true);
|
||||
}, MINIMUM_LOAD_TIME);
|
||||
return () => window.clearTimeout(timeout);
|
||||
});
|
||||
|
||||
// we add a minimum (but short) load time here so that
|
||||
// there isn't a quick flash of loading and immediately
|
||||
// another flash to the tweets screen.
|
||||
const hasLoaded = tweets && minimumLoadPassed;
|
||||
|
||||
if (!hasLoaded) return <TweetSkeletonList />;
|
||||
return (
|
||||
<List>
|
||||
{tweets.map((tweet) => (
|
||||
<Tweet key={tweet.id} {...tweet} />
|
||||
))}
|
||||
</List>
|
||||
);
|
||||
}
|
||||
|
||||
export default TweetList;
|
||||
Reference in new issue
Block a user