-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
useGetUser
토큰을 넣으면 해당 유저에 대한 정보를 가져옵니다. (useQuery 이용)
사용예시
const Main = () => {
// 토큰가져오기
const { accessToken } = useToken();
// 유저 정보가져오기, data : userInfo 에 유저에 대한 정보가 저장됩니다.
const { data: userInfo, isLoading: fetchingUser } = useGetUser(accessToken);
return (
{fetchingUser ? (
<SkeletonLoanProductCard />
) : (
<TotalLoans
amount={userInfo?.availableAmount}
onClick={handleTotal}
/>
)}
)
}정의
import { useQuery } from '@tanstack/react-query';
import React from 'react';
import { ax } from '../axiosClient';
import useToken from './useToken';
interface IUserInfo {
availableAmount: number;
birth: string;
email: string;
job: string;
name: string;
phone: string;
salary: number;
}
const useGetUser = (accessToken, options?) => {
return useQuery<IUserInfo>(['user'], () => ax.getUser(accessToken), {
...options,
});
};
export default useGetUser;Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation