-
Notifications
You must be signed in to change notification settings - Fork 9
github_start_9 민경빈 과제 제출합니다. #4
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
base: master
Are you sure you want to change the base?
Conversation
lallaheeee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mobx 코드는 처음 봤는데 짱 신기하네요 경빈님 덕에 mobx 코드도 읽어여 ㅎㅎ
고생하셨습니다!! 👍🏻
src/hooks/useInput.ts
Outdated
| export default function useInput(initialForm: State) { | ||
| const [state, dispatch] = useReducer(reducer, initialForm); | ||
| const onChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| if (e.target.validity.valid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input에는 validity라는 프로퍼티도 있군요..! 어떨 때 사용하나요?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input의 프로퍼티에 pattern이라는 값이 있는데 여기에다가 정규식(?) 양식을 넣을 수 있어요. 이때 이 양식에 맞지 않으면 validty.valid 값이 false로 리턴 됩니당
하지만 지금은 필요없다고 생각해서 삭제했습니다 ㅋㅋㅋㅋ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
와 짱이네요 새로운 거 알아갑니다~ 👍🏻
|
|
||
| const Container = styled.div``; | ||
|
|
||
| const Header = styled.div` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
시맨틱하게 header 어떤가여 ㅎㅎ
| const Header = styled.div` | |
| const Header = styled.header` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/config.ts
Outdated
| @@ -0,0 +1,5 @@ | |||
| const config = { | |||
| APISERVERPATH: "https://api.github.com", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_로 구분지어주면 더 보기 좋을것 같아요!
API_SERVER_PATH
src/components/RepoItem/index.tsx
Outdated
| } | ||
|
|
||
| export const RepoItem: React.FC<Props> = (props) => { | ||
| const { html_url, full_name, stargazers_count } = props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API응답을 바로 넣어주느라 snake case 를 사용하신것 같은데
다른 부분에서도 camelCase를 사용했으니 camelCase로 통일해주는게 어떨까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const { html_url, full_name, stargazers_count } = props; | |
| const { html_url: htmlUrl, full_name: fullName, stargazers_count: starCount } = props; |
이런식으로 선언하면 무방할까요??
src/containers/Main.tsx
Outdated
| const userInfo = useMemo(() => { | ||
| return ( | ||
| store.username && ( | ||
| <UserInfo> | ||
| <UserName>{store.username}</UserName> | ||
| <Count>{store.repoCount} Repositories</Count> | ||
| <Count>{store.totalStars} Stars</Count> | ||
| </UserInfo> | ||
| ) | ||
| ); | ||
| }, [store.username, store.repoCount, store.totalStars]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
component로 사용되는 변수 같아보이는데 변수명을 Pascal case로 UserInfo 어떤가요??
밑부분의 style component는 Styled prefix를 붙여주고여!
convention을 통일하는게 좋다고 생각해요!ㅎㅎ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뭔가 useMemo로 선언하는 구문은 변수 같기도하고, styled-components 이름과 자주 겹치기도 해서 camel Case로 쓰는거 같네요... 좋은거 같아요!
src/stores/store.ts
Outdated
| import axios from 'axios'; | ||
| import { action, computed, flow, observable } from 'mobx'; | ||
|
|
||
| import config from '../config'; | ||
|
|
||
| const { APISERVERPATH } = config; | ||
|
|
||
| export default class Store { | ||
| @observable data = []; | ||
|
|
||
| @observable username: string = ""; | ||
|
|
||
| @action | ||
| fetchData = flow(function* (this: Store, username: string) { | ||
| const response = yield axios.get(`${APISERVERPATH}/users/${username}/repos`); | ||
|
|
||
| if (response.status === 200) { | ||
| this.username = username; | ||
| this.data = response.data; | ||
| } | ||
| }); | ||
|
|
||
| @computed | ||
| get totalStars() { | ||
| return this.data.reduce((prev, next: any) => prev + next.stargazers_count, 0); | ||
| } | ||
|
|
||
| @computed | ||
| get repoCount() { | ||
| return this.data.length; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mobx 사용한 코드를 처음봤는데 재밌을 것 같아요! 많이 배울 수 있겠어요ㅎㅎ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 덕분에 context로 된 코드 보고있습니다 👍
|
|
||
| if (isLocalhost) { | ||
| // This is running on localhost. Let's check if a service worker still exists or not. | ||
| checkValidServiceWorker(swUrl, config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkValidServiceWorker 보단 validateServiceWorker가 더 간단하지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음 프로젝트 생성하면서 자동으로 만들어진 파일이긴한데 저 파일이 어떤 용도로 쓰이는지부터 알아보겠습니다!
| @@ -0,0 +1,34 @@ | |||
| import axios from 'axios'; | |||
| import { action, computed, flow, observable } from 'mobx'; | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 mobx.. 나중에 mobx 관련 발표도 고려 해주시면 좋을것 같슴다..! 궁금해요 몹엑스!
| "name": "github_star", | ||
| "version": "0.1.0", | ||
| "private": true, | ||
| "dependencies": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 리뷰에 있던 내용이긴 한데 dependencies와 devDependencies 분리하는것도 좋아 보입니다.
package.json
Outdated
| "test": "react-scripts test", | ||
| "eject": "react-scripts eject" | ||
| }, | ||
| "eslintConfig": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것도 다른 리뷰에 있던건데 설정들 다른 파일로 뺄수 있는건 빼는것도 좋아 보입니다.
| @@ -0,0 +1,43 @@ | |||
| <!DOCTYPE html> | |||
| <html lang="en"> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 다른 리뷰에 있던 내용인데 ko로 바꾸는건 어떨까요?
src/containers/App.tsx
Outdated
| return ( | ||
| <BrowserRouter> | ||
| <Switch> | ||
| <Route exact path="/" component={Main} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
라우트가 하나뿐인데 react-router-dom을 쓰신 이유가 있을까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처음에 Main 페이지로 store를 inject했을 때, Provider를 달고도 따로 store를 주입해야하더라구요.
근데 react-router-dom을 쓰면 별 다른 처리를 하지 않아도 되서 그렇게 처리했는데
이렇게 수정할 계획입니다
| <Route exact path="/" component={Main} /> | |
| const injected = props as InjectedProps; | |
| const { store } = injected; |
| const repoItems = useMemo(() => { | ||
| return store.data.map((el) => <RepoItem {...el} />); | ||
| }, [store.data]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RepoItem컴포넌트에 key 속성을 넣어주지 않아도 렌더링에 문제없나요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
엇 key를 깜빡했네요 감사합니다!
| <Input onChange={onChange} name="username" onKeyUp={handleKeyUp} /> | ||
| <StyledButton onClick={handleSearch}>Search</StyledButton> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
username을 입력하는 input과 search버튼 대신 form태그를 사용하여 묶고 button대신 input태그의 submit type을 사용해보는건 어떨까요? 이렇게 하면 위의 handleKeyUp이벤트에서 눌린 버튼이 엔터인지 검사하지 않아도 form 태그가 알아서 엔터키 이벤트를 감지할 수 있을것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
form 태그가 엔터키 이벤트를 감지하는건 처음 알았네요 새로운거 하나 배워갑니다~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 저도 처음 알았어요
rdd9223
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
몹엑스와 styled-components 신기하고 흥미로웠습니다!! 배울 점이 많았던 코드같아요 ㅎㅎ 고생하셨습니다!
| }, [htmlUrl]); | ||
|
|
||
| return ( | ||
| <Wrapper onClick={handleRedirect}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
styled-components를 처음봐서 굉장히 신기하네요!!!
style 컴포넌트만 따로 모듈화 시켜서 쓰는 방법도 있나요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 저도 아직 익숙하진 않은데 쓰기에 따라 많은 방면에 활용될거 같습니다...!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
소소한 이야기 이지만,
onClick으로 링크를 이동시키는 것 보다, a tag 등을 활용하시는 것이 SEO와 accessibility에 좋습니다.
https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뭔가 페이지를 이동한다기보단, 데이터 fetching을 하는 느낌이라 함수를 이용했습니다.
eastroots92
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드가 매우 깔끔하네요 👍
| @@ -0,0 +1,25 @@ | |||
| { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 CRA에서 manifest도 생성해줬나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그런거 같네요 제가 따로 만들진 않았으니...ㅎ
| }, [htmlUrl]); | ||
|
|
||
| return ( | ||
| <Wrapper onClick={handleRedirect}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
소소한 이야기 이지만,
onClick으로 링크를 이동시키는 것 보다, a tag 등을 활용하시는 것이 SEO와 accessibility에 좋습니다.
https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML
|
|
||
| interface Props extends RepoType {} | ||
|
|
||
| export const RepoItem: React.FC<Props> = (props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export const RepoItem: React.FC<Props> = (props) => { | |
| export const RepoItem: React.FC<Props> = ({ htmlUrl, fullName, starCount }: Props) => { |
다음과 같이 할 수 도 있습니다.
| `; | ||
|
|
||
| const UserName = styled.div` | ||
| color: #495057; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주로 사용하는 컬러가 정해져 있는 듯 한데
color Theme 하나 만들어서 사용해도 좋을 것 같아요!
| const Wrapper = styled.div` | ||
| padding: 12px 0px; | ||
| border-bottom: 1px solid #ced4da; | ||
| margin-bottom: 24px; | ||
| `; | ||
|
|
||
| const UserName = styled.p` | ||
| font-weight: 300; | ||
| color: #343a40; | ||
| font-size: 42px; | ||
| margin: 0; | ||
| `; | ||
|
|
||
| const Count = styled.span` | ||
| font-weight: 400; | ||
| color: #343a40; | ||
| font-size: 24px; | ||
| padding-right: 12px; | ||
|
|
||
| & + span { | ||
| border-left: 2px solid #343a40; | ||
| padding-left: 12px; | ||
| } | ||
| `; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
component 들을 folder로 구분 지으셨던 것 같은데, 요것도 styles.ts 등과 같이 구분 짓는 것은 어떻게 생각하세요?
그러면 관심사가 분리되어 보기 더 좋을 것 같단 생각이 들어서요!
src/containers/Main.tsx
Outdated
|
|
||
| const handleKeyUp = useCallback( | ||
| (e: React.KeyboardEvent<HTMLInputElement>) => { | ||
| if (e.keyCode === 13) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
정말 소소하긴 하지만, 개인적으로는 13과 같은 내용들도 상수로 빼려고 노력하는 편이에요!
13이 어떤 key인지 모르시는 분들도 있기 때문에 아래와 같이 해서 협업하시는 분들이 좀 더 읽기 편하게 하기 위해서 입니다.
enum KEY_CODE {
ENTER: 13,
};
if (e.keyCode === KEY_CODE.ENTER) {}| <Input onChange={onChange} name="username" onKeyUp={handleKeyUp} /> | ||
| <StyledButton onClick={handleSearch}>Search</StyledButton> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 저도 처음 알았어요
|
|
||
| import { RepoType } from '../../types'; | ||
|
|
||
| interface Props extends RepoType {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RepoType이 Type으로 정의되어있는 것 같은데 extneds로 해도 정상동작하나요??
typescript 가 버전 업 될때마다 급진적이게 이것저것 추가되어 제가 놓친 것 일수도있어용..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 알기론 저기선 Props가 type으로 선언되어있으면 extends가 안되는걸로 알아요 (저 코드에서 타입추론이 되긴 합니다)
| font-size: 14px; | ||
| padding: 8px 12px; | ||
| opacity: 0.7; | ||
| border: 1px solid #868e96; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
css를 width|height, font, background처럼 항목별로 묶어서 표현하면 더 읽기 좋아질것 같아요!

No description provided.