/
githubmirror
/
wp-calypso
Обзор
Документация
Войти
/
githubmirror
/
wp-calypso
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/api-queries/src/user.ts
18 строк
618 B
Mehmood Ahmad
Reader: Improve user hovercard performance by using custom implementation (#109865)
24 апр 2026, 03:24
Не верифицирован
24 апр 2026, 03:24
ce0aad6
Код
Авторство
О чём код?
import { fetchUserProfile } from '@automattic/api-core'; import { queryOptions } from '@tanstack/react-query'; export const userQuery = ( userLogin?: string, userId?: string | number, enabled: boolean = true ) => { const userIdOrLogin = userLogin || userId; const params = ! userLogin && userId ? { find_by_id: true } : {}; // If userLogin is not provided, we will try to find the user by ID. return queryOptions( { queryKey: [ 'user', userIdOrLogin, params ], queryFn: () => fetchUserProfile( userIdOrLogin!, params ), enabled: !! userIdOrLogin && enabled, staleTime: 5 * 60000, // 5 minutes } ); };