-
Notifications
You must be signed in to change notification settings - Fork 128
[리뷰 요청] 2주차 1번 과제 #185
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
Open
ctaaag
wants to merge
8
commits into
CodeSoom:ctaaag
Choose a base branch
from
ctaaag:main
base: ctaaag
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[리뷰 요청] 2주차 1번 과제 #185
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2ce7408
feat: 1차 과제 완료
ctaaag 25da462
fix: 린트 에러 해결
ctaaag 7423a20
fix : App, index 파일 분리
ctaaag ea12862
fix: components 폴더 생성
ctaaag c246ad8
fix:린트에러 및 컴포넌트명 변경
ctaaag 0168378
fix: 린트에러 해결
ctaaag db9870e
fix: 더할 숫자 외부 변수로 주입 및 props로 넘길 핸들러함수명 변경
ctaaag a378bf5
fix: number 속성 이름 추상화 반영
ctaaag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import React, { useState } from 'react'; | ||
| import ClickMeButton from './components/ClickMeButton'; | ||
| import NumberButtons from './components/NumberButtons'; | ||
|
|
||
| export default function App() { | ||
| const [counterNumber, setCounterNumber] = useState(0); | ||
|
|
||
| function handlerClickButton({ number }) { | ||
| setCounterNumber(counterNumber + number); | ||
| } | ||
|
|
||
| return ( | ||
| <div> | ||
| <p>Counter</p> | ||
| <ClickMeButton | ||
| counterNumber={counterNumber} | ||
| onClick={handlerClickButton} | ||
| whatNumberToAdd={1} | ||
| /> | ||
| <br /> | ||
| <NumberButtons onClick={handlerClickButton} /> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React from 'react'; | ||
|
|
||
| export default function ClickMeButton({ | ||
| counterNumber, | ||
| onClick, | ||
| whatNumberToAdd, | ||
| }) { | ||
| return ( | ||
| <button type="button" onClick={() => onClick({ number: whatNumberToAdd })}> | ||
| Click me ({counterNumber}) | ||
| </button> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import React from 'react'; | ||
|
|
||
| export default function NumberButtons({ handlerClickButton }) { | ||
| return [1, 2, 3, 4, 5].map((i) => ( | ||
| <button type="button" onClick={() => handlerClickButton({ number: i })}> | ||
| {i} | ||
| </button> | ||
| )); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom'; | ||
| import App from './App'; | ||
|
|
||
| ReactDOM.render(<App />, document.getElementById('app')); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
감사합니다 :) 덕분에 추상화를 항상 유념하면서 코드를 짜게 되는 것 같아요!
속성명을 number로 변경해서 해당 컴포넌트에서만 명확한 역할을 알게 수정했습니다!