1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-21 20:44:18 +00:00

🔧 Immensely improve performance in the RepositoryViewer

This commit is contained in:
Steffo 2021-05-23 16:07:18 +02:00
parent 6af52643d1
commit 2c57bd0238
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -1,4 +1,4 @@
import React from "react"
import React, { useMemo } from "react"
import BoxFullScrollable from "../base/BoxFullScrollable"
import SummaryTweet from "./SummaryTweet"
import Empty from "./Empty"
@ -18,13 +18,18 @@ export default function BoxRepositoryTweets({ ...props }) {
const strings = useStrings()
const { tweets } = useRepositoryViewer()
let content
if(tweets.length === 0) {
content = <Empty/>
}
else {
content = tweets.map(tweet => <SummaryTweet key={tweet["snowflake"]} tweet={tweet}/>)
}
const content = useMemo(
() => {
if(tweets.length === 0) {
return <Empty/>
}
else {
return tweets.map(tweet => <SummaryTweet key={tweet["snowflake"]} tweet={tweet}/>)
}
},
[tweets]
)
return (
<BoxFullScrollable header={strings.tweets} {...props}>