-
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
Week7 #9
Week7 #9
Changes from 1 commit
457ccdf
428d1fc
78340c1
c78ceba
c562585
3f72d9a
f50321e
540fc68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export interface letter { | ||
export interface Letter { | ||
id: number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 호곡! 나는 편지마다 id 값을 넣을 생각을 못해서 인덱스로 접근했는데 맞네맞네 id 중요하지!!!! 꼼꼼하게 넘 잘했다아~ |
||
writer: string; | ||
title: string; | ||
|
@@ -7,8 +7,8 @@ export interface letter { | |
password: string; | ||
} | ||
|
||
export interface letterDataProps { | ||
letterData: letter; | ||
export interface LetterDataProps { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 음,,, 어떤게 비슷하다는거지?! letterDataProps -> LetterDataProps 바꾼 이유말하는건가? 그거는 type 명을 대문자로 시작하게 통일하고 싶어서 수정했어! |
||
letterData: Letter; | ||
} | ||
export interface UseInterval { | ||
(callback: () => void, interval: number): void; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,11 @@ import React, { useState } from "react"; | |
import styled from "styled-components"; | ||
import Swal from "sweetalert2"; | ||
import withReactContent from "sweetalert2-react-content"; | ||
import { letter, letterDataProps } from "../common/type"; | ||
import { Letter, LetterDataProps } from "../common/type"; | ||
import { useInterval } from "../utils/useInterval"; | ||
|
||
const Letter = (letterData: letterDataProps) => { | ||
const letter: letter = letterData.letterData; | ||
const LetterItem = (letterData: LetterDataProps) => { | ||
const letter: Letter = letterData.letterData; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 그렇군요!! 정확하게(개발자의 의도대로) 자동추론 되는거는 개발자가 선언 안하고 넘겨도 되나요? |
||
const [isOpened, setIsOpened] = useState(false); | ||
const [content, setContent] = useState(""); | ||
const [count, setCount] = useState(0); | ||
|
@@ -157,4 +157,4 @@ const LetterInfo = styled.section` | |
} | ||
`; | ||
|
||
export default Letter; | ||
export default LetterItem; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ import React from "react"; | |
import { useNavigate } from "react-router-dom"; | ||
import { useState, useEffect } from "react"; | ||
import styled from "styled-components"; | ||
import Letter from "../components/letter"; | ||
import { letter } from "../common/type"; | ||
import LetterItem from "../components/letterItem"; | ||
import { Letter } from "../common/type"; | ||
|
||
const MainPage = () => { | ||
const navigate = useNavigate(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. navigate에도 찾아보니까 type 선언을 해줄 수 있더라고!! 근데 이러한 선언을 꼭 필요한지는.. 같이 생각해보면 좋을 것 같아! |
||
const [letters, setletters] = useState<letter[]>([]); | ||
const [letters, setletters] = useState<Letter[]>([]); | ||
|
||
const getLetters = () => { | ||
fetch("/letters") | ||
|
@@ -34,8 +34,8 @@ const MainPage = () => { | |
<WriteButton onClick={gotoWrite}>편지쓰기</WriteButton> | ||
</Header> | ||
<LetterContainer> | ||
{letters.map((letterData: letter) => { | ||
return <Letter key={letterData.id} letterData={letterData} />; | ||
{letters.map((letterData: Letter) => { | ||
return <LetterItem key={letterData.id} letterData={letterData} />; | ||
})} | ||
</LetterContainer> | ||
</> | ||
|
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 interface을 밖에서 선언해주는 방법 좋은 것 같아!!