-
Notifications
You must be signed in to change notification settings - Fork 0
[박서연] 커스텀 훅 실습 #5
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: main
Are you sure you want to change the base?
Conversation
seoyeon435
commented
Jul 30, 2025
- useWindowSize 구현
- useCountdown 구현
- useAlert 구현 (버튼을 누르면 "안뇽!! 내 인스타 아이디야 -> seoyeon_435 " alert 가 뜹니다)
| export const useModal = () => { | ||
| // 여러분의 use{Something}을 만들어주세요! | ||
| // 정답은 없습니다. 커스텀훅의 필요성을 스스로 느껴보세요. | ||
| // 아이디어를 생각하고, 스스로 구현하다가 어려우면 손 들어주세요! |
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 [timeLeft, setTimeLeft] = useState(() => calculateTimeLeft(targetDate)); | ||
| // return () => clearInterval(timer); | ||
| // }, [targetDate]); |
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 modal = () => { | ||
| alert("안뇽!! 내 인스타 아이디야 -> seoyeon_435 "); | ||
| }; | ||
|
|
||
| return { modal }; | ||
|
|
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 modal = () => { | ||
| alert("안뇽!! 내 인스타 아이디야 -> seoyeon_435 "); |
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.
버튼을 누르면 인스타 아이디가 뜨는 게 귀엽네요!
함수 이름을 showAlert() , showMessage() 처럼 직관적으로 해도 좋을 것 같네요
| // 아이디어를 생각하고, 스스로 구현하다가 어려우면 손 들어주세요! | ||
| }; | ||
| const modal = () => { | ||
| alert("안뇽!! 내 인스타 아이디야 -> seoyeon_435 "); |
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.
간단하지만 굉장히 직관적인 코드인 거 같아요 !! 인스타 아이디가 뜨는 것도 너무 귀여운 발상이에용
modal 이라는 함수명을 조금 더 구체적으로 작성하는 것도 좋을 거 같아요 !
Soi-coding
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.
과제하시느라 수고하셨어요!
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.
메세지 내용이 귀여워요! 함수명을 modal이라고 하셨지만 기본 alert만 사용하고 계셔서 함수명을 다르게 바꾸면 좋을 것 같아요!
| // 아이디어를 생각하고, 스스로 구현하다가 어려우면 손 들어주세요! | ||
| }; | ||
| const modal = () => { | ||
| alert("안뇽!! 내 인스타 아이디야 -> seoyeon_435 "); |
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.
아이디어가 너무 귀여워요!! 버튼을 누르면 alert창이 뜨도록 구현한 점이 인상 깊습니다. ui를 따로 만들어서 새로운 모달창이 뜨도록 해봐도 재밌을 것 같아요!
| // 아이디어를 생각하고, 스스로 구현하다가 어려우면 손 들어주세요! | ||
| }; | ||
| const modal = () => { | ||
| alert("안뇽!! 내 인스타 아이디야 -> seoyeon_435 "); |
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가 modal보다는 openModal 같은 이름이 더 직관적일 것 같습니다
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.
모달창 띄우기를 커스텀훅으로 지정한점이 인상 깊은 것 같아요! .jsx 파일 이름도 명확하게 바꿔서 설정해놓으면 더 좋을 것 같아용