Skip to content

Commit

Permalink
fix: memo select fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Jul 9, 2023
1 parent bbe249b commit b78a1ac
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'use client'

import { useQuery } from '@tanstack/react-query'
import React, { createElement, forwardRef, useEffect, useRef } from 'react'
import React, {
createElement,
forwardRef,
useCallback,
useEffect,
useRef,
} from 'react'
import clsx from 'clsx'
import { m, useInView } from 'framer-motion'
import Link from 'next/link'
Expand Down Expand Up @@ -474,20 +480,20 @@ const NoteScreen = () => {

const FriendScreen = () => {
const { data } = useQuery({
queryKey: ['home', 'friends', 'random'],
queryKey: ['friends'],
queryFn: async () => {
return apiClient.friend.getAll().then((res) => {
return res.data
})
},
select(data: LinkModel[]) {
select: useCallback((data: LinkModel[]) => {
return shuffle(
data.filter(
(i) =>
i.type === LinkType.Friend && i.state === LinkState.Pass && !i.hide,
),
).slice(0, 20)
},
}, []),
staleTime: 1000 * 60,
})
return (
Expand Down

0 comments on commit b78a1ac

Please sign in to comment.