Skip to content

Commit

Permalink
fix: 优化瀑布流渲染
Browse files Browse the repository at this point in the history
  • Loading branch information
besscroft committed Jul 30, 2024
1 parent c8b039d commit a3208fb
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions components/Masonry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ import { FloatButton } from 'antd'

import 'react-photo-album/masonry.css'

function renderNextImage(
{ alt = '', title, sizes }: RenderImageProps,
{ photo }: RenderImageContext,
dataList: never[],
) {
return (
<BlurImage photo={photo} dataList={dataList} />
);
}

export default function Masonry(props : Readonly<ImageHandleProps>) {
const { data: pageTotal } = useSWRPageTotalHook(props)
const { data, error, isLoading, isValidating, size, setSize } = useSWRInfinite((index) => {
Expand All @@ -34,15 +44,6 @@ export default function Masonry(props : Readonly<ImageHandleProps>) {
(state) => state,
)

function renderNextImage(
{ alt = '', title, sizes }: RenderImageProps,
{ photo }: RenderImageContext,
) {
return (
<BlurImage photo={photo} dataList={dataList} />
);
}

useEffect(() => {
const fetchData = async (id: number) => {
try {
Expand Down Expand Up @@ -84,7 +85,7 @@ export default function Masonry(props : Readonly<ImageHandleProps>) {
...item
})) || []
}
render={{ image: renderNextImage }}
render={{image: (...args) => renderNextImage(...args, dataList)}}
/>
<div className="flex items-center justify-center my-4">
{
Expand Down

0 comments on commit a3208fb

Please sign in to comment.