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

[web] Integrate Next.js with MUI v5 #58

Closed
wants to merge 4 commits into from
Closed

[web] Integrate Next.js with MUI v5 #58

wants to merge 4 commits into from

Conversation

jordan-choi
Copy link
Contributor

@jordan-choi jordan-choi commented Mar 5, 2022

Related issues

Resolves #57

Description

Next.js + MUI v5 + TypeScript Example

Test

@jordan-choi jordan-choi added the ⚙️ setting 프로젝트 setting에 관한 issue/PR label Mar 5, 2022
@jordan-choi jordan-choi added this to the 0.0.3 milestone Mar 5, 2022
@jordan-choi jordan-choi requested a review from a team March 5, 2022 12:30
Comment on lines +19 to +21
"@emotion/cache": "^11.7.1",
"@emotion/react": "^11.8.0",
"@emotion/server": "^11.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

@jordan-choi@emotion/cache@emotion/server는 무슨 역할이에요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • @emotion/server의 경우, <head> 안에 critical CSS를 넣기 위해서 사용합니다. @emotion/servercreateEmotionServer 메서드로 커스텀 서버를 만들고 criticalCSS를 추출한 후(extractCriticalToChunks) <style> 태그로 만들어 initialProps에 포함시킵니다.
  • 모든 SSR 요청마다 같은 emotion 캐시를 공유하기 위해, CacheProvider에서 (default 캐시가 아닌) custom cache를 제공하는데요. 이 때 공유할 custom cache를 만들 때 @emotion/cachecreateCache 메서드를 사용합니다.
  • custom cache를 사용하려는 이유는 developer defined <style> 태그를 사용하기 위해서 입니다 (참고: Primary use cases of createCache).
  • 위의 사항에 대해서는 이 이슈에서 자세히 다루고 있습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

@emotion/server는 js로 다뤄지는 css는 런타임에서 인라인으로 스타일을 공급하는데. 그렇게 하면 초기 렌더링시 레이아웃에 영향을 미치는 중요한(아마도 이게 critical css) 스타일들은 js페칭이 될 때까지 적용이 안될테니. 그걸 ssr 에서 head에 넣기 위해 제공되나 보군요.
cache는 왜 필요한지 아직 몰라서 써봐야 알겠네요. 자세한 답변감사합니다~!

@jordan-choi jordan-choi self-assigned this Mar 5, 2022
@JeGwan JeGwan self-requested a review March 12, 2022 10:04
@jordan-choi jordan-choi deleted the web/i57 branch March 12, 2022 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️ setting 프로젝트 setting에 관한 issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[web] Integrate Next.js with MUI v5
4 participants