Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ 4주차 기본과제 ] Github Profile Finder #6

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

myeongheonhong
Copy link
Collaborator

✨ 구현 기능 명세

  • 기본 과제
  1. Finder에서 검색이름 검색 시 api 호출을 통해 github data를 받아오는 기능.
  2. 받아온 github data를 Content컴포넌트를 통해 정보를 보여주는 기능.
  3. 최근 검색한 목록을 보여주는 history 기능(추가 및 삭제 버튼클릭 시 목록에서 제거).

🎁 PR Point

  • Main
  1. bringUsername을 통해 input창에서 입력한 아이디가 전달 되었을때 api를 통해 해당 데이터를 githubData에 저장 & githubSearchList(history)에 이름을 추가한다.
  2. 호출이 완료할 시 Content컴포넌트를 보여주는 openContent를 통해 정보를 출력한다.
  3. githubSearchList(history)에서는 중복됨을 방지하고자 Set을 이용하여서 추가하고 객체로 변환한다(내장함수를 이용하기위해)

-Finder

  1. handleOnClick : input창이 클릭 되었을 때 history를 보여준다.
  2. handleOutside : 다른곳을 클릭하였을 때 historty를 닫는다.
  3. handleDeleteClick : 목록의 X버튼 클릭시 목록에서 해당 검색기록을 삭제해준다.
  4. handleHistoryClick : input에서 동작하는 방식을 해당 검색기록에 해당하는 유저를 보여주는 기능을 그대로 구현한다.
  • Content
  1. githubData에 들어 있는 정보를 보여준다.

😭 소요 시간, 어려웠던 점

  • 약8시간..?
  1. 앞으로 과제구현하기전에 천천히 기능명세서를 작성 해야겠습니다.
  2. 리라돔 구현해야되는지 모르고 쩔쩔매면서 눈물흘리면서 했습니다.
  3. 아직 리액트 구조잡는게 어려운거 같습니다...ㅠㅠㅠㅠㅠ

😎 구현 결과물

Uploading 화면 기록 2022-11-11 오후 5.44.28.mov…

- Finder에서 엔터 이벤트가 발생 하였을시 input.value값을 부모 컴포넌트에 전달하여 username에 해당하는 정보를 가져옴.
- username에 해당하는 정보가 없거나 요청시 에러가 발생할 경우 에러처리.
- 요청성공시 최신검색에 username을 저장할 githubUserList에 username을 할당 & 해당 user의 데이터를 저장하는 githubData에 정보를 할당.
- handleOnClick : input창이 클릭 될 시 최신검색기록이 보여짐(hidden=false)로 변경.
- handleOutside : input창 외에 다른 부분 클릭 시 최신검색기록 사라짐(hidden=true)로 변경.
- 보여짐(!hidden)의 경우 map을 이용하여 최신검색기록에 있는 username을 컴포넌트를 이용하여 출력.
- 클릭 이벤트가 발생한 형제요소의 innerText를 props로 받아온 deleteUsername에 전달해주어 해당하는 이름을 githubSearchList에서 제거한다
Copy link
Contributor

@joohaem joohaem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생했어 !!! 골머리 앓았겠다

다른 파트원들 코드 보면서, router 를 이용해서 어떻게 데이터를 주고받았나 확인해보면 좋을 것 같아 !~

@@ -0,0 +1 @@
# 안녕 나는 홍명헌이야~
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI~

Copy link

@leeseooo leeseooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번주 과제도 역시 잘 해주셨네요 최고짱짱

Comment on lines +18 to +27
.then((resopnse) => {
if (resopnse['status'] === 200) {
setGithubData(resopnse['data']);
setGithubSearchList((prev) => [
...new Set(prev).add(username),
]);
setOpenContent(true);
}
})
.catch((error) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요기서는 catch에서 에러를 잡아주고 있어서 19번째 조건문은 없어도 될 것 같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 .then이 성공했을 때 실행이 될테니 이 말이 맞군요!!반영하겠습니당!!

Comment on lines +47 to +51
<Finder
bringUsername={bringUsername}
githubSearchList={githubSearchList}
deleteUsername={deleteUsername}
></Finder>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컴포넌트 태그 사이에 특정 요소를 넣어주고 있지 않다면 <Finder /> 요렇게 클로징 태그로 써주면 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 맞네요!! 반영하겠습니다!!ㅎㅎㅎ

const { githubData, deleteContent } = props;
return (
<ContentContainer>
<Outlet />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

중첩 라우팅 이렇게 편하게 할 수 있었군요~ 꿀팁 알아가요 👍👍👍

근데 지금 Content 컴포넌트가 /search 경로에 있는 Main 컴포넌트 안에서 중첩 라우팅이 되고 있으니까
Content 컴포넌트가 아니라 Main 컴포넌트에서 Outlet을 사용해야 하는 것 같은데 제가 이해한 게 맞을까요??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants