-
Notifications
You must be signed in to change notification settings - Fork 1
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
[7주차 과제] 웹 비밀 편지 만들기 #6
Conversation
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 default function Header() { | ||
return ( | ||
<h1>💌웹 비밀 편지💌</h1> |
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,6 @@ | |||
export interface List { |
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 interface List { | |
export interface LetterInfo |
로 조금더 인터페이스명이 명확했음 좋겠다!
그리구 types/common.ts로 했는데, 여기서는 공통으로 타입이 사용되는게 맞지만 만약 기능이 많다면, types/letter.ts
로 파일명 지정하는게 관리하기 편할거야!
<> | ||
<Header/> | ||
<button type='button'>글쓰기</button> | ||
{messages.map(({writer, message},i) => ( |
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.
i 보다는 idx 라고 지칭해주자! 너무 약어는 지양하자구>.<
axios.post("/letters", | ||
{ | ||
"writer": writer, | ||
"message": message, | ||
"password": password, | ||
"hint": hint | ||
} | ||
).then((res) => { | ||
console.log(res) | ||
axios.get("/letters") | ||
.then((res) => { | ||
setMessage("") | ||
setMessages(res.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.
src/lib폴더를 만들고, axios로 instance 만든다음에 그 객체를 사용해서 letterApi.ts 만들고 내부에서 post 함수 export해서 import하는 방법으로 코드를 짜보자!
|
||
<button disabled={!message}>추가</button> | ||
</form> | ||
<button disabled={!message}>추가</button> |
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.
버튼 타입오디쪄!
interface SecretList{ | ||
hint:string; | ||
password:string | ||
} | ||
|
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.
interface SecretList{ | |
hint:string; | |
password:string | |
} | |
interface CheckModalProps{ | |
hint:string; | |
password:string | |
} |
로 사용하는게 적당하지아느까?! 그냥 나의 개인적인 의견!! 왜냠 컴포넌트의 props로 사용하고 이쓰니까아!!
interface SecretList{ | ||
hint:string; | ||
password:string | ||
} | ||
|
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.
interface SecretList{ | |
hint:string; | |
password:string | |
} | |
interface CheckModalProps{ | |
hint:string; | |
password:string | |
} |
로 사용하는게 적당하지아느까?! 그냥 나의 개인적인 의견!! 왜냠 컴포넌트의 props로 사용하고 이쓰니까아!!
) | ||
} | ||
|
||
const StCheckModalWrapper=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.
article은 어떄?!
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 default function CheckModal({hint, password}:SecretList): JSX.Element { | ||
const [visible, setVisible] = useState<boolean>(true) | ||
const [text, setText]=useState<string>("") |
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.
이렇게 빼먹지 않고 State에도 타입선언 다 해주는거 너무 좋다!!
worker.start(); | ||
} | ||
|
||
const root = ReactDOM.createRoot( |
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.
이런 root에도 타입 선언이 있으면 좋지 않을까 하는 의견..!
fetchData(); | ||
}, []); | ||
|
||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { |
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.
FormEvent를 이용해서 이런식으로 타입 선언을 해주는 구조구나.. 또 배워갑니다!!
@@ -0,0 +1,11 @@ | |||
export interface List { |
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.
이렇게 필요한 type들 외부에서 구분해주는거 좋은거같아!!
✨ 구현 기능 명세
🎁 PR Point
req.body
를await req.json()
으로 바꾸어주니 잘 되었습니다.function CheckModal({hint, password}:SecretList): JSX.Element
<input type="text" placeholder="글쓴이" onChange={({ target: { value } }) => setWriter(value)}/>
😭 소요 시간, 어려웠던 점
10h
😎 구현 결과물
2022-12-28.4.18.47.mov
2022-12-28.4.29.02.mov
📚 레퍼런스
타입스크립트 초기세팅
타입스크립트 msw
타입스크립트 msw 타입 지정
타입스크립트 msw POST
타입스크립트 msw req.body 에러 해결방법
JSON.parse
POST fetch로 구현
css grid 사용하기
타입스크립트 이벤트 타입 지정