티스토리 뷰

"use client";

import { useSession } from "@/hooks/useUserProfile";
import supabase from "../../../utils/supabase/client";
import { useEffect, useState } from "react";
import { Database, Tables } from "../../../../database.types";

const ApplyStudyList = () => {
  const [studyApplyList, setStudyApplyList] = useState([]);

  //유저 정보 가져오기

  const { data: user } = useSession();
  console.log(user);

  useEffect(() => {
    //   스터디 신청 데이터 가져오기
    const getStudyApplyList = async () => {
      const { data , error } : {data : Tables<"study_applylist">[], error : null} = await supabase
        .from("study_applylist")
        .select("*")
        .eq("user_id", user?.id);
      if (error) {
        console.error(
          "Error fetching data getStudyApplyList : ",
          error.message,
        );
      } else if (data) {
        console.log("유저 스터디 신청 데이터 test", data);
        setStudyApplyList(data );
      }
    };
    getStudyApplyList();
  }, []);

  return <div>{studyApplyList}</div>;
};

export default ApplyStudyList;

스터디 그룹 페이지를 하는데 타입 설정이 좀 막혔음.

hellozero님한테 물어보니까 tanstack query를 사용하는 법을 가르쳐 주셨고 그걸 쓰니까 코드가 훨씬 깔끔해지고 쓰기 쉬워지는 걸 봤음.

낼 한 세시까지 투자해서 tanstack query를 좀 연습하려고 함. 오늘은 이제 좀 쉬고

waterhe님도 그렇고 실력자들이 옆에 있어서 배울 게 많아서 좋다.

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함