Skip to content
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

3์กฐ #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

3์กฐ #4

wants to merge 1 commit into from

Conversation

Valentin1495
Copy link

@Valentin1495 Valentin1495 commented Mar 17, 2023

๐Ÿ† ํ”„๋กœ์ ํŠธ ์ œ๋ชฉ ๐Ÿ†

YouTube

๐Ÿ“Œ ํ”„๋กœ์ ํŠธ ์†Œ๊ฐœ ๐Ÿ“Œ

Google์—์„œ ์ œ๊ณตํ•˜๋Š” YouTube API๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์™€ YouTube ์•ฑ์„ ๋งŒ๋“ ๋‹ค.

๐Ÿ‘ค ํŒ€์› ์†Œ๊ฐœ ๐Ÿ‘ค

๐Ÿ“š ๊ธฐ์ˆ  ์Šคํƒ ๐Ÿ“š

โฐ ๊ณผ์ œ ์ง„ํ–‰ ๊ธฐ๊ฐ„ โฐ

2023.3.10 ~ 2023.3.16

โœ ์ž‘์—… ์˜์—ญ ๋ฐ ๊ตฌํ˜„ ๊ธฐ๋Šฅ ์„ค๋ช… โœ

โ—พ ๊น€์‘์—ด


๐Ÿ”ป ํ™ˆํŽ˜์ด์ง€ header์™€ sidebar, sidebar modal ๊ตฌํ˜„

๐Ÿ”ป ํ™ˆํŽ˜์ด์ง€ ๋น„๋””์˜ค ์นด๋“œ ์Šคํƒ€์ผ๋ง

โ—พ ์žฅ๊ฑด์šฐ


๐Ÿ”ป Mainpage, Channelpage, MainComponent ๊ตฌํ˜„

๐Ÿ”ป ํ™ˆํŽ˜์ด์ง€ ๋น„๋””์˜ค ์ด๋ฏธ์ง€, ๋น„๋””์˜ค ํƒ€์ดํ‹€, ์ฑ„๋„ ์ด๋ฆ„, ๋‚ ์งœ ๋“ฑ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ Œ๋”๋ง

๐Ÿ”ป ChannelPage๋Š” ๋ฉ”์ธํŽ˜์ด์ง€์˜ ์ฑ„๋„์ด๋ฆ„์„ ๋ˆ„๋ฅด๋ฉด ์ด๋™ํ•˜๋„๋ก ๊ตฌํ˜„ํ•˜์˜€๊ณ 

useEffect๋กœ ํ•ด๋‹น channelId๋ฅผ ํ™œ์šฉํ•˜์—ฌ(useParams๋กœ ๊ฐ€์ ธ์˜ด)
axios๋กœ api ํ˜ธ์ถœ์„ ํ•ด์„œ ์ฑ„๋„ ๊ด€๋ จ ๋น„๋””์˜ค๊ฐ€ 10๊ฐœ ๋ฐ›์•„์ง€๋„๋ก ๊ตฌํ˜„

โ—พ ์ตœ์šฐ์„ฑ


๐Ÿ”ป SearchPage, SearchMain ๊ตฌํ˜„

๐Ÿ”ป useState์™€ useEffect๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฒ€์ƒ‰์–ด๋ฅผ ์ €์žฅ. ๊ฒ€์ƒ‰์–ด๋Š” useParams๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ URL์—์„œ ๊ฐ€์ ธ์˜ค๊ณ ,
๊ทธ ๊ฒฐ๊ณผ๋ฅผ SearchMain ์ปดํฌ๋„ŒํŠธ์— ์ „๋‹ฌํ•˜์—ฌ ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๋Š” ๊ฒƒ์„ ๊ตฌํ˜„

โ—พ ์ดํ˜„์ •


๐Ÿ”ป DetailPage ๊ตฌํ˜„ ์‹œ ์˜ค๋ฅ˜

์–ด๋ ค์› ๋˜ ์  ๐Ÿ˜น

๐Ÿ”ป styled-components๋ฅผ ํ™œ์šฉํ•  ๋•Œ props ์ด์šฉํ•˜์—ฌ modal์„ ์—ด๊ณ  ๋‹ซ๋Š” ๊ฒƒ๊ณผ ๋ฐ˜์‘ํ˜• ๊ตฌํ˜„ํ•˜๋Š” ๋ถ€๋ถ„์ด ํž˜๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ”ป Youtube api ํ˜ธ์ถœ์— ์ œํ•œ์ด ์žˆ์–ด์„œ ๊ทธ ๋ถ€๋ถ„์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด localstorage๋กœ ๋Œ€์ฒ˜ํ•˜๋Š” ๋ถ€๋ถ„์ด ๊นŒ๋‹ค๋กญ๊ฒŒ ๋Š๊ปด์กŒ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ async await ๋น„๋™๊ธฐ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ถ€๋ถ„์ด ์กฐ๊ธˆ ๊นŒ๋‹ค๋กœ์› ์Šต๋‹ˆ๋‹ค.

๐Ÿ”ป api๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด์„œ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์˜ค๋ฅ˜๋“ค์ด ๋‚ฌ์—ˆ๊ณ  ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๊ฒƒ์ด ์–ด๋ ค์› ์Šต๋‹ˆ๋‹ค.
๋˜ api์˜ ๋ถˆํ•„์š”ํ•œ ํ˜ธ์ถœ์„ ์ตœ์†Œํ™”ํ•˜๋Š” ๊ฒƒ์ด๋‚˜ ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ๊ฒ€์ƒ‰์–ด๋งŒ ๊ฐ€์ ธ์˜ค๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ด ์ƒ๊ฐ๋ณด๋‹ค ๊นŒ๋‹ค๋กœ์› ์Šต๋‹ˆ๋‹ค. useState ๋‚˜ useEffect ๊ฐ™์€ Hook์„ ์ ์žฌ์ ์†Œ์— ์ž˜ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์–ด๋ ค์› ์Šต๋‹ˆ๋‹ค.

@Valentin1495 Valentin1495 self-assigned this Mar 17, 2023
Comment on lines +9 to +14
<style>
body {
margin: 0;
box-sizing: border-box;
}
</style>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index.html์„ ํ†ตํ•ด ๋ณ„๋„๋กœ ๊ธ€๋กœ๋ฒŒ css๋ฅผ ์ ์šฉํ•˜๋Š”๊ฒƒ๋ณด๋‹ค
ํ†ต์ผ์„ฑ์žˆ๊ฒŒ styled component๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ด ๊ด€๋ฆฌ์ธก๋ฉด์—์„œ ๋ณด๋‹ค ์ข‹์€ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.
์ ์šฉ๊ณผ ๊ด€๋ จ๋œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ createGlobalStyle๋ฅผ ์ฐธ๊ณ ํ•˜์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ•ด๋‹น ๋‚ด์šฉ์€ /src/index.css์—๋„ ๋™์ผํ•˜๊ฒŒ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.


const Layout = () => {
const [showModal, setShowModal] = useState(false);
const [inputdata, setInputData] = useState("")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inputdata๋ฅผ camelCase๋กœ ํ†ต์ผ์‹œ์ผœ์ฃผ์„ธ์š”

Copy link

@KDT-sihyeon KDT-sihyeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ํ•˜์‹œ๋Š๋ผ ๊ณ ์ƒ ๋งŽ์œผ์…จ์Šต๋‹ˆ๋‹ค.
์ „๋ฐ˜์ ์œผ๋กœ ์•„์‰ฌ์› ๋˜ ๋‚ด์šฉ์—๋Œ€ํ•ด ๋ช‡๊ฐ€์ง€ ์ฝ”๋ฉ˜ํŠธ ๋“œ๋ฆฌ๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

  1. ์ปดํฌ๋„ŒํŠธ ๋ถ„๋ฆฌ๊ฐ€ ์ž˜ ์ด๋ฃจ์–ด์ง€์ง€ ์•Š์€๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ํŠนํžˆ styled-component๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ ์žˆ์–ด ๊ณต์šฉ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ๋‚ด์šฉ์„ ๋ถ„๋ฆฌํ•˜๊ฑฐ๋‚˜ ์—ญํ• ๋ณ„๋กœ ๋ถ„๋ฆฌ๋˜์–ด ์žˆ์ง€ ์•Š๋Š”์ ์„ ์ง‘์ค‘์ ์œผ๋กœ ์ˆ˜์ •ํ•ด๋‚˜๊ฐ€์‹œ๊ธธ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.
  2. vh, vw์™€ ๊ฐ™์€ ์š”์†Œ๋Š” ๋ฐ˜์‘ํ˜•์œผ๋กœ css๋ฅผ ์ ์šฉํ•˜๋Š”๋ฐ ์–ด๋ ค์›€์„ ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. calc๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ•˜๋“œ์ฝ”๋”ฉํ•˜๊ฒŒ ๋˜๋ฉด ๊ตฌ์„ฑ ์š”์†Œ์— ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ์ƒ๊ฒผ์„ ๋•Œ ์ด๋ฅผ ๋ฐ˜์˜ํ•˜๊ธฐ ์–ด๋ ค์›Œ์ง‘๋‹ˆ๋‹ค. root๋ฅผ ์ œ์™ธํ•œ ์ปดํฌ๋„ŒํŠธ์—์„œ๋Š” ์‚ฌ์šฉ์„ ์ตœ๋Œ€ํ•œ ์ง€์–‘ํ•˜๊ณ  ๋‹ค๋ฅธ ๋ฐฉํ–ฅ์œผ๋กœ ๊ตฌํ˜„ํ•ด๋ณด์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค. (๋‹ค๋งŒ ์ •๋ง ํ•„์š”ํ•œ ์ƒํ™ฉ์—์„œ๋Š” ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ด ๋งž์Šต๋‹ˆ๋‹ค.)
  3. rem, px๋ฅผ ํ˜ผ์šฉํ•˜์—ฌ ์‚ฌ์šฉํ•˜๊ธฐ๋ณด๋‹ค๋Š” ํ•œ๊ฐ€์ง€๋กœ ํ†ต์ผ์„ฑ ์žˆ๊ฒŒ ์ž‘์—…ํ•˜์‹œ๋Š”๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค. rem์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด font-size ์กฐ์ ˆ์„ ํ†ตํ•ด ๋ฐ˜์‘ํ˜• ์›นํŽ˜์ด์ง€๋ฅผ ๊ตฌํ˜„ํ•ด๋ณด์‹œ๋Š” ๋ฐฉํ–ฅ์œผ๋กœ ์ž‘์—…ํ•˜์‹œ๋Š”๊ฒƒ์ด ๋ณด๋‹ค ๋ชฉ์ ์— ๋งž์Šต๋‹ˆ๋‹ค. ์ด์™€ ๊ด€๋ จ๋œ ๋‚ด์šฉ์„ ์ฐพ์•„๋ณด์‹œ๋Š”๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.

Comment on lines +56 to +66
<Routes>
<Route path='/' element={<Layout />}>
{/* <Route index element={<HomePage />} /> */}
<Route index element={<MainPage />} />
<Route path=':movieId' element={<DetailPage />} />
<Route path='search/:searchId' element={<SearchPage />}/>
<Route path='channel'>
<Route index path=':channelId' element={<ChannelPage />} />
</Route>
</Route>
</Routes>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Routes๋Š” ๋ณ„๋„์˜ ํด๋”๋ฅผ ๋งŒ๋“ค์–ด ๊ด€๋ฆฌํ•˜๋Š”๊ฒƒ์ด ์ถ”ํ›„์— ์ฐพ์•„๋ณด๊ธฐ ํŽธ๋ฆฌํ• ๊ฒƒ๊ฐ™์Šต๋‹ˆ๋‹ค.

Comment on lines +21 to +23
<svg className='hamburger' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'>
<path d='M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z' />
</svg>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FontAwesomeIcon ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ๋™์ผํ•œ ์•„์ด์ฝ˜์ด ์žˆ๋Š”๋ฐ๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ๋ณ„๋„๋กœ svg๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์€ ๋ถˆํ•„์š”ํ•œ ํ–‰๋™์œผ๋กœ ์ธ์‹๋ฉ๋‹ˆ๋‹ค.
์ถ”๊ฐ€๋กœ svg๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ๋‚˜์œ๊ฒƒ์€ ์•„๋‹ˆ๋‚˜ png๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ด ์ด๋ฏธ์ง€๋ฅผ ๋ณ„๋„๋กœ ๊ด€๋ฆฌํ•˜๋Š”๋ฐ ์ด์ ์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ
png๋กœ ์ œ๊ณต ๋ฐ›์„์ˆ˜ ์žˆ์„ ๊ฒฝ์šฐ svg๋ณด๋‹ค png๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.

Comment on lines +20 to +27
const fetchData = async () => {
await axios(requests.fetchPopularVideo).then(res => {
const data = res.data.items;
console.log(data);
setYoutubeData(data);
localStorage.setItem('PopularVideo', JSON.stringify(data));
});
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async-await ๊ตฌ๋ฌธ๊ณผ promise.then ๊ตฌ๋ฌธ์„ ํ˜ผ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

Suggested change
const fetchData = async () => {
await axios(requests.fetchPopularVideo).then(res => {
const data = res.data.items;
console.log(data);
setYoutubeData(data);
localStorage.setItem('PopularVideo', JSON.stringify(data));
});
};
const fetchData = async () => {
const {data} = await axios(requests.fetchPopularVideo)
setYoutubeData(data.items);
localStorage.setItem('PopularVideo', JSON.stringify(data.items));
};

Comment on lines +112 to +120
const Row = ({ items }) => {
return (
<Container>
{items.map((item) => (
<VideoItem key={item.id} data={item} />
))}
</Container>
);
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Row์™€ ๊ฐ™์ด ๋„ˆ๋ฌด ์ถ”์ƒํ™”๋œ ๋„ค์ด๋ฐ์œผ๋กœ ์ธํ•ด Row Component๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ํŒŒ์ผ์—์„œ ์ง๊ด€์ ์œผ๋กœ ์ดํ•ดํ•˜๊ธฐ ์–ด๋ ต์Šต๋‹ˆ๋‹ค.
VideoItems๊ณผ ๊ฐ™์ด ๋ณด๋‹ค ์ง๊ด€์ ์ธ ์ด๋ฆ„์„ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.

Comment on lines +14 to +15
frameborder: '0',
allowfullscreen: 'allowfullscreen',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSX์—์„œ๋Š” HTML attribute๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  camelCase๋กœ ์ž‘์„ฑํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.
๋ณด๋‹ค ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๊ณต์‹๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

Comment on lines +76 to +101
const VideoItem = ({ data }) => {
const movieId = data.id.videoId;

return (
<Link to={`/${movieId}`} style={{ textDecoration: 'none' }}>
<VideoContainer>
<ImgWrapper>
<ThumbnailImg
src={data.snippet.thumbnails.maxres?.url || data.snippet.thumbnails.default?.url}
alt={data.snippet.title}
/>
</ImgWrapper>

<Thumbnail>
<Title>{data.snippet.title}</Title>
<Link to={`/channel/${data.snippet.channelId}`} style={{ textDecoration: 'none' }}>
<Section>
<span>{data.snippet.channelTitle}</span>
<span>{moment(data.snippet.publishedAt).fromNow()}</span>
</Section>
</Link>
</Thumbnail>
</VideoContainer>
</Link>
);
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/components/MainComponents/Row.js์—์„œ ๋™์ผํ•œ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉ์ค‘์— ์žˆ์Šต๋‹ˆ๋‹ค.
styled-component๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์žฌ์‚ฌ์šฉ์„ฑ์„ ํฌ๊ธฐํ•˜๋Š”๊ฒƒ์€ styled-component๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ์— ์œ„๋ฐฐ๋˜๋Š” ํ–‰๋™์ž…๋‹ˆ๋‹ค.
์žฌ์‚ฌ์šฉ์„ฑ ๊ฐ€๋Šฅํ•˜๋„๋ก props๋ฅผ ๋ฐ›๋Š” component๋ฅผ ๋งŒ๋“ค๊ฑฐ๋‚˜ styled-component๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.

axios.get(`/search?part=snippet&maxResults=10&q=${searchId}`)
.then(response => {
console.log(response.data)
const responsedata = response.data.items

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

responseData์™€ ๊ฐ™์ด camelCase๋กœ ๋ณ€๊ฒฝํ•˜์‹œ๋Š”๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.

Comment on lines +12 to +23
async function getChannelData() {
try {
const response = await axios(requests.fetchChannelData(channelId));
const cdata = response.data.items;
setChannelData(cdata);
const response2 = await axios(requests.fetchPlayLists(channelId));
const vdata = response2.data.items;
setChannelVideo(vdata);
} catch (error) {
console.log(error);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response, response2์™€ ๊ฐ™์ด ๋ฌด์˜๋ฏธํ•œ ๋ณ€์ˆ˜๋ช…์„ ๋ถ€์—ฌํ•˜๋Š”๊ฒƒ์€ ์ข‹์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

Suggested change
async function getChannelData() {
try {
const response = await axios(requests.fetchChannelData(channelId));
const cdata = response.data.items;
setChannelData(cdata);
const response2 = await axios(requests.fetchPlayLists(channelId));
const vdata = response2.data.items;
setChannelVideo(vdata);
} catch (error) {
console.log(error);
}
}
async function getChannelData() {
try {
const {data: channelData} = await axios(requests.fetchChannelData(channelId));
setChannelData(channelData.items);
const {data: playLists} = await axios(requests.fetchPlayLists(channelId));
setChannelVideo(playLists.items);
} catch (error) {
console.log(error);
}
}

Comment on lines +9 to +19
const Modal = styled.div`
position: fixed;
top: 75px;
height: calc(100vh - 75px);
width: 208.3px;
background-color: white;
transition: transform 300ms;
z-index: 10;
transform: ${({ showModal }) =>
showModal ? 'translateX(0)' : 'translateX(-100%)'};
`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฐ’์„ ํ•˜๋“œ์ฝ”๋”ฉํ•˜์—ฌ css๋ฅผ ์ ์šฉํ•˜๋Š” ๋ฐฉ์‹์€ ๋‹ค์ง€์•ˆ ๋ณ€๊ฒฝ์‚ฌํ•ญ์— ์œ ์—ฐํ•˜๊ฒŒ ๋Œ€์ฒ˜ํ•˜๊ธฐ ์–ด๋ ค์›Œ ์ตœ๋Œ€ํ•œ ์ง€์–‘ํ•˜๋Š”๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด width์™€ ๊ฐ™์€ ๊ฒฝ์šฐ ๊ณ ์ • px๋ฅผ ์ง€์ •ํ•˜๊ธฐ๋ณด๋‹ค padding๊ฐ’์„ ํ†ตํ•ด ์—ฌ๋ฐฑ์„ ์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด
๋™์ผํ•œ ๋””์ž์ธ์„ ๋ณด์—ฌ์ฃผ์ง€๋งŒ ์œ ์—ฐํ•œ ์ฝ”๋“œ๊ฐ€ ๋ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

Comment on lines +5 to +7
const DetailPage = () => {
let { movieId } = useParams();
console.log(movieId);
Copy link

@KDT-sihyeon KDT-sihyeon Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ๋„ฃ์œผ์‹œ๊ณ  ๋กœ๊ทธ์— ๋‚˜์˜ค๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ํ™•์ธํ•˜์‹œ๋ฉฐ ๋””ํ…Œ์ผ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋งˆํฌ์—… ํ•ด๋ณด์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

useEffect(() => {(async ()=> {
    if (movieId) {
      const response = await axios(requests.fetchDetailVideo(movieId));
      console.log(response)
    }
  })();
  },[movieId]);

@KDT-sihyeon
Copy link

KDT-sihyeon commented Mar 23, 2023

์–ด๋ ค์› ๋˜์ ๊ณผ ๊ด€๋ จ๋œ ์ฝ”๋ฉ˜ํŠธ์ž…๋‹ˆ๋‹ค.

๐Ÿ”ป styled-components๋ฅผ ํ™œ์šฉํ•  ๋•Œ props ์ด์šฉํ•˜์—ฌ modal์„ ์—ด๊ณ  ๋‹ซ๋Š” ๊ฒƒ๊ณผ ๋ฐ˜์‘ํ˜• ๊ตฌํ˜„ํ•˜๋Š” ๋ถ€๋ถ„์ด ํž˜๋“ค์—ˆ์Šต๋‹ˆ๋‹ค.

useState์™€ ํ•จ๊ป˜ ์ž˜ ์‚ฌ์šฉํ•˜์…จ์Šต๋‹ˆ๋‹ค. container ์ž์ฒด๋ฅผ modal๋กœ ์‚ฌ์šฉํ•˜๊ธฐ๋ณด๋‹ค modal๋กœ ๋‚˜ํƒ€๋‚  element๋ฅผ ํ•œ๊ฐœ ์ถ”๊ฐ€ํ•˜์—ฌ ๋ณ„๋„๋กœ ๊ด€๋ฆฌํ•˜๋Š”๊ฒƒ์ด ๋ณด๋‹ค ์œ ์—ฐํ•˜๊ฒŒ ์‚ฌ์šฉ๊ธฐ ์ข‹์Šต๋‹ˆ๋‹ค. (z-index๋“ฑ์„ ์ ์šฉ์‹œํ‚ค๋Š”๋ฐ ์ด์ )

๐Ÿ”ป Youtube api ํ˜ธ์ถœ์— ์ œํ•œ์ด ์žˆ์–ด์„œ ๊ทธ ๋ถ€๋ถ„์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด localstorage๋กœ ๋Œ€์ฒ˜ํ•˜๋Š” ๋ถ€๋ถ„์ด ๊นŒ๋‹ค๋กญ๊ฒŒ ๋Š๊ปด์กŒ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ async await ๋น„๋™๊ธฐ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ถ€๋ถ„์ด ์กฐ๊ธˆ ๊นŒ๋‹ค๋กœ์› ์Šต๋‹ˆ๋‹ค.

localStorage์˜ ๊ฒฝ์šฐ ๋ฌธ์ž์—ด ๊ฐ’๋งŒ ๋“ค์–ด๊ฐˆ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ์— JSON.parse๋‚˜ JSON.stringify๋“ฑ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
์ด๋ฅผ ๊ธฐ์–ตํ•˜๊ณ  ๊ณ„์‹œ๋ฉด ๋ณด๋‹ค ์ ์šฉํ•˜๋Š”๋ฐ ๋„์›€์ด ๋ ๊ฒƒ์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค.

async-await ๊ตฌ๋ฌธ์˜ ์‚ฌ์šฉ์ด ์–ด๋ ต๋‹ค๋ฉด Promise.then๊ณผ์˜ ์ƒ๊ด€๊ด€๊ณ„์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•ด๋ณด์‹œ๋Š”๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ”ป api๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด์„œ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์˜ค๋ฅ˜๋“ค์ด ๋‚ฌ์—ˆ๊ณ  ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๊ฒƒ์ด ์–ด๋ ค์› ์Šต๋‹ˆ๋‹ค.
๋˜ api์˜ ๋ถˆํ•„์š”ํ•œ ํ˜ธ์ถœ์„ ์ตœ์†Œํ™”ํ•˜๋Š” ๊ฒƒ์ด๋‚˜ ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ๊ฒ€์ƒ‰์–ด๋งŒ ๊ฐ€์ ธ์˜ค๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ด ์ƒ๊ฐ๋ณด๋‹ค ๊นŒ๋‹ค๋กœ์› ์Šต๋‹ˆ๋‹ค. useState ๋‚˜ useEffect ๊ฐ™์€ Hook์„ ์ ์žฌ์ ์†Œ์— ์ž˜ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์–ด๋ ค์› ์Šต๋‹ˆ๋‹ค.

api๋ฅผ ํ˜ธ์ถœํ•˜์‹œ๋ฉฐ ๊ฒช์œผ์‹  ์˜ค๋ฅ˜๋“ค์ด ์–ด๋–ค๊ฒƒ์ธ์ง€ ๋ชฐ๋ผ ์ž์„ธํ•œ ํ”ผ๋“œ๋ฐฑ์„ ๋“œ๋ฆฌ๊ธฐ ์–ด๋ ต์Šต๋‹ˆ๋‹ค.
์ดํ›„ ํ”„๋กœ์ ํŠธ์—์„œ github๋‚ด issue๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‚จ๊ฒจ๋‘์‹ ๋‹ค๋ฉด ํŒ€์›์„ ๋น„๋กฏํ•˜์—ฌ ์—ฌ๋Ÿฌ ์‚ฌ๋žŒ๋“ค์ด ๋‚ด์šฉ์„ ๊ณต์œ ๋ฐ›๊ธฐ ์ข‹์„๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

useState์™€ useEffect๋ฅผ ์ž˜ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” react์˜ life-cycle๊ณผ ๊ด€๋ จ๋œ ๋‚ด์šฉ์„ ์ดํ•ดํ•˜๊ณ  ์žˆ๋Š”๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.
์•„๋ž˜ ๊ณต์‹๋ฌธ์„œ๋ฅผ ์ฝ์–ด๋ณด์‹œ๋Š”๊ฒƒ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants