Coder Social home page Coder Social logo

get_issues's Introduction

원하는 User의 Repo의 IssueList 불러오기

원하는 유저의 저장소의 이슈들을 불러올 수 있는 프로젝트 입니다.
배포링크: https://graceful-sunburst-ef9ec3.netlify.app/main

getissue.mp4

기술스택

목표

특정 깃헙 레파지토리의 이슈 목록과 상세 내용을 확인하는 웹 사이트 구축

  1. 이슈 목록 화면

  2. 이슈 상세 화면

    • 이슈의 상세 내용 표시
    • ‘이슈번호, 이슈제목, 작성자, 작성일, 코멘트 수, 작성자 프로필 이미지, 본문' 표시

커스텀 훅을 만들어 데이터 불러오기

import { useState, useEffect } from "react";
import { Octokit } from "@octokit/rest";
import { useRecoilState } from "recoil";
import { issuesState } from "../libs/recoil/Issue";

export type Repo = {
  user: string;
  repo: string;
};

function useGithubIssues(curRepoInfo: Repo, page: number) {
  const [issues, setIssues] = useRecoilState(issuesState);
  const [loading, setLoading] = useState(false);
  const [error, setError] = useState<Error | null>(null);

  // Repo정보가 변경되면 issue정보 초기화
  useEffect(() => {
    setIssues([]);
  }, [curRepoInfo]);

  useEffect(() => {
    const fetchIssues = async () => {
      setLoading(true);
      // const octokit = new Octokit({
      //   auth: `${process.env.REACT_APP_GIT_API}`,
      // });

      const octokit = new Octokit();

      try {
        setLoading(true);
        const response = await octokit.issues.listForRepo({
          owner: curRepoInfo.user,
          repo: curRepoInfo.repo,
          state: "open",
          page: page,
          number: 30,
          sort: "comments",
        });

        const newIssues = response.data;

        setIssues((prev) => [...prev, ...newIssues]);
      } catch (error) {
        console.error("Error fetching issues:", error);
        setError(error as Error);
      } finally {
        setLoading(false);
      }
    };

    if (curRepoInfo.user && curRepoInfo.repo) {
      fetchIssues();
    }
  }, [page, curRepoInfo]); // page나 curRepoInfo가 변경될 때만 실행

  return { issues, loading, error };
}

GitHub 토큰을 사용하지 않으면 시간당 60개 호출만 가능하기 때문에 최상위 경로에 .env파일에 토큰을 발급받아 프로젝트에 사용하면 제한 없이 사용할 수 있습니다.

Commit convetnion

Type 설명
feat 새로운 기능 추가
fix 버그 수정 또는 오타
refactor 코드 리팩토링
design 사용자 UI 디자인 변경 (CSS 등)
comment 필요한 주석 추가 및 변경
style 코드 포맷팅, 세미콜론 누락, 코드 변경이 없는 경우
test 테스트 코드 추가, 수정, 삭제, 비즈니스 로직 변경이 없는 경우
chore 위에 해당되지 않는 기타 변경사항 (빌드 스크립트, 패키지 등)
init 프로젝트 초기 생성
rename 파일 또는 폴더명 수정 또는 이동
remove 파일을 삭제하는 작업만 수행하는 경우

get_issues's People

Contributors

yjason-k avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.