Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"lint-staged": "^15.5.1",
"prettier": "^3.5.3",
"prettier-plugin-tailwindcss": "^0.6.11",
"react-youtube": "^10.1.0",
"tailwindcss": "^4",
"tw-animate-css": "^1.2.9",
"typescript": "^5",
Expand Down
70 changes: 70 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/features/post/contents/react-compiler.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ thumbnail: '/images/react-compiler-thumbnail.webp'

그러던 중 우연히 유튜브 숏츠를 보다가 제로초 채널에서 React Compiler 1.0에 대해 소개하는 영상을 만나보게 되었다.

<YouTube videoId="JVKT7z8w5q0" title="리액트가 알아서 성능최적화를 해준다...? (React compiler, 리액트 컴파일러 정식 출시)" />

[리액트가 알아서 성능최적화를 해준다...? (React compiler, 리액트 컴파일러 정식 출시)](https://youtube.com/shorts/JVKT7z8w5q0?si=fqdeVTPfRInWCMkY)

대충 React.memo, useMemo, useCallback 등을 사용하지 않아도 React가 알아서 성능 최적화를 해준다는 내용이었다. 조금 더 찾아보니 실제로 코드를 작성해보며 리액트 컴파일러를 사용했을때와 하지 않았을때를 비교하는 영상도 발견할 수 있었다.

<YouTube videoId="4WyLSzwRMGg" title="리액트가 알아서 성능최적화를 해준다...? (React compiler, 리액트 컴파일러 정식 출시)" />

[React Compiler 1.0 완벽 정리|드디어 베타 끝!](https://youtu.be/4WyLSzwRMGg?si=zrW_HlS4vNeAGuHj)

이 영상을 통해 리액트 컴파일러를 사용하게 되면 React 에서 알아서 불필요한 리렌더링을 방지해주고, 메모이제이션 또한 자동으로 처리해준다는 것을 알 수 있었다.
Expand Down
4 changes: 4 additions & 0 deletions src/shared/components/features/mdx/MDXComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { MDXComponents } from 'mdx/types';

import { YouTube } from '../youtube';

export const mdxComponents: MDXComponents = {
// 제목 스타일링 (반응형)
h1: ({ children }) => (
Expand Down Expand Up @@ -121,4 +123,6 @@ export const mdxComponents: MDXComponents = {
{children}
</td>
),

YouTube,
};
31 changes: 31 additions & 0 deletions src/shared/components/features/youtube/YouTubeEmbed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client';

import YouTube, { YouTubeProps } from 'react-youtube';

type Props = {
videoId: string;
title: string;
};

export const YouTubeEmbed = ({ videoId, title }: Props) => {
const opts: YouTubeProps['opts'] = {
width: '100%',
height: '100%',
playerVars: {
autoplay: 0,
modestbranding: 1,
rel: 0,
},
};

return (
<div className='relative my-8 aspect-video w-full'>
<YouTube
className='absolute top-0 left-0 h-full w-full'
opts={opts}
title={title}
videoId={videoId}
/>
</div>
);
};
Comment on lines +1 to +31
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

opts 객체는 렌더링될 때마다 재생성될 필요가 없는 상수입니다. 컴포넌트 외부로 옮겨서 불필요한 재생성을 방지하는 것이 좋습니다. 이렇게 하면 성능에 미미하지만 긍정적인 영향을 줄 수 있고, 코드의 의도를 더 명확하게 표현할 수 있습니다.

'use client';

import YouTube, { YouTubeProps } from 'react-youtube';

type Props = {
  videoId: string;
  title: string;
};

const YOUTUBE_OPTS: YouTubeProps['opts'] = {
  width: '100%',
  height: '100%',
  playerVars: {
    autoplay: 0,
    modestbranding: 1,
    rel: 0,
  },
};

export const YouTubeEmbed = ({ videoId, title }: Props) => {
  return (
    <div className='relative my-8 aspect-video w-full'>
      <YouTube
        className='absolute top-0 left-0 h-full w-full'
        opts={YOUTUBE_OPTS}
        title={title}
        videoId={videoId}
      />
    </div>
  );
};

1 change: 1 addition & 0 deletions src/shared/components/features/youtube/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { YouTubeEmbed as YouTube } from './YouTubeEmbed';