mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
optimize tweet list to not re-render unless tweets change
This commit is contained in:
1 parent
04e685baa6
commit
e89107a8a1
1 file changed
+4
-2
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState, memo } from "react";
|
||||
|
||||
import { List } from "../../../../ui/components/List";
|
||||
import Tweet from "./Tweet";
|
||||
@@ -21,7 +21,9 @@ export function TweetList({ tweets }) {
|
||||
// another flash to the tweets screen.
|
||||
const hasLoaded = tweets && minimumLoadPassed;
|
||||
|
||||
|
||||
if (!hasLoaded) return <TweetSkeletonList />;
|
||||
console.log(tweets.length);
|
||||
return (
|
||||
<List>
|
||||
{tweets.map((tweet) => (
|
||||
@@ -31,4 +33,4 @@ export function TweetList({ tweets }) {
|
||||
);
|
||||
}
|
||||
|
||||
export default TweetList;
|
||||
export default memo(TweetList); // only re-render if our tweets change
|
||||
Reference in new issue
Block a user