Skip to content

Commit ed1d5f5

Browse files
authored
Merge pull request #1438 from scroll-tech/fix-protocol-key
fix: protocol key
2 parents 607edb1 + 2a95d1d commit ed1d5f5

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

src/app/ecosystem/Protocols/ProtocolList/ProtocolCard.tsx

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import Image from "next/image"
12
import { useRef, useState } from "react"
2-
import Img from "react-cool-img"
33
import { makeStyles } from "tss-react/mui"
44

55
import { Box, Button, Stack, SvgIcon, Typography } from "@mui/material"
@@ -15,6 +15,18 @@ import useCheckViewport from "@/hooks/useCheckViewport"
1515

1616
import NetworkLabel from "./NetworkLabel"
1717

18+
export interface Protocol {
19+
name: string
20+
desc: string
21+
ext: string
22+
// networkLabel: "Mainnet" | "Testnet"
23+
networkLabel: string
24+
rank: object
25+
tags: string[]
26+
twitterHandle: string
27+
website: string
28+
}
29+
1830
const useStyles = makeStyles()(theme => ({
1931
grid: {
2032
backgroundColor: theme.vars.palette.themeBackground.normal,
@@ -123,7 +135,7 @@ const useStyles = makeStyles()(theme => ({
123135
}))
124136

125137
const ProtocolCard = props => {
126-
const { name, hash, ext, tags, desc, website, twitterHandle, networkLabel, onResize, className, ...restProps } = props
138+
const { name, ext, tags, desc, website, twitterHandle, networkLabel, onResize, className, ...restProps } = props
127139
const { classes, cx } = useStyles()
128140
const { isMobile, isDesktop } = useCheckViewport()
129141

@@ -146,7 +158,13 @@ const ProtocolCard = props => {
146158
gridArea: "logo",
147159
}}
148160
>
149-
<Img alt={name} src={fetchEcosystemProtocolLogo(name, ext)} placeholder={hash} width={isMobile ? 48 : 88} height={isMobile ? 48 : 88}></Img>{" "}
161+
<Image
162+
alt={name}
163+
src={fetchEcosystemProtocolLogo(name, ext)}
164+
placeholder="empty"
165+
width={isMobile ? 48 : 88}
166+
height={isMobile ? 48 : 88}
167+
></Image>
150168
</Stack>
151169
<Stack direction="row" alignItems="center" gap="0.8rem" className={classes.name}>
152170
<Typography

src/app/ecosystem/Protocols/ProtocolList/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { isAboveScreen } from "@/utils/dom"
1414

1515
import Error from "./Error"
1616
import NoData from "./NoData"
17-
import ProtocolCard from "./ProtocolCard"
17+
import ProtocolCard, { type Protocol } from "./ProtocolCard"
1818

1919
const useStyles = makeStyles()(theme => ({
2020
listRoot: {
@@ -36,7 +36,7 @@ const ProtocolList = props => {
3636
const { classes } = useStyles()
3737
const [loading, setLoading] = useState(false)
3838
const prePage = usePrevious(page)
39-
const [ecosystemList, setEcosystemList] = useState([])
39+
const [ecosystemList, setEcosystemList] = useState<Protocol[]>([])
4040
const [isError, setIsError] = useState(false)
4141
const [hasMore, setHasMore] = useState(false)
4242

@@ -46,7 +46,9 @@ const ProtocolList = props => {
4646
estimateSize: () => 136,
4747
overscan: 5,
4848
gap: 20,
49+
4950
scrollMargin: listRef.current?.offsetTop ?? 0,
51+
getItemKey: index => ecosystemList[index].name,
5052
})
5153
const rows = virtualizer.getVirtualItems()
5254

src/components/LinesEllipsis/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function prevSibling(node, count) {
3636
}
3737

3838
const LinesEllipsis = props => {
39-
const { component: Component = "div", ellipsis, trimRight = true, basedOn, maxLine = 1, text, className, onReflow, ...rest } = props
39+
const { component: Component = "div", ellipsis, trimRight = true, basedOn, maxLine = 1, text, className, ...rest } = props
4040

4141
const [displayedText, setDisplayedText] = useState(text)
4242
const [clamped, setClamped] = useState(false)
@@ -92,7 +92,7 @@ const LinesEllipsis = props => {
9292
const nextDisplayedText = nextClamped ? units.current.slice(0, ellipsisIndex).join("") : props.text
9393
setClamped(nextClamped)
9494
setDisplayedText(nextDisplayedText)
95-
onReflow({ clamped: nextClamped, text: nextDisplayedText })
95+
// onReflow({ clamped: nextClamped, text: nextDisplayedText })
9696
}
9797

9898
// return the index of the first letter/word of each line

0 commit comments

Comments
 (0)