๋ฒ๊ทธ๊ฐ ๋ฌด์์ธ์ง ๋ช ํํ๊ณ ๊ฐ๊ฒฐํ๊ฒ ์ค๋ช ํฉ๋๋ค.
Next.js๋ฅผ ์ฌ์ฉํ ๋ <div id="__next">
์์๊ฐ ์ฒ์ ํ์ ๋ ๋ CSS๊ฐ <head>
๋ก ์์ ํ ์ํ๋์ง ์์ ๊ฒ์ผ๋ก ๋ณด์
๋๋ค.
์ด๋ก ์ธํด ๊ฐ๋ฐ ์๋ฒ๋ฅผ ์คํํ ๋ ์คํ์ผ์ด ์ง์ ๋์ง ์์ ์ฝํ ์ธ (๋๋ FOUC)๊ฐ ๊น๋ฐ์ ๋๋ค. ๊ทธ๋๋ ํ๋ก๋์ ์์ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์ต๋๋ค (์ด์ํ๊ฒ ๋ณด์ ๋๋ค).
๋์์ ์ฌํํ๋ ๋จ๊ณ, ์ฝ๋ ์กฐ๊ฐ ๋๋ ์ ์ฅ์๋ฅผ ์ ๊ณตํ์ญ์์ค.
$ git clone https://github.com/tutorbookapp/covid-tutoring
README.md
)์ ์ค์นํฉ๋๋ค.$ npm i && lerna bootstrap --hoist
$ npm run dev
์์ํ๋ ์ผ์ ๋ํ ๋ช ํํ๊ณ ๊ฐ๊ฒฐํ ์ค๋ช .
<div id="__next">
์์ ๋ง (์ ํฌํจ๋๋ ์คํ์ผ ์ํธ๊ฐ ๋ฐฐ ์๊ธฐ ํ์๋๋ ๊ตฌ์ฑ ์์ ๋ฐ์ ์ฆ,)์ ์ฝ์
๋๋ ํ์ํ ์คํฌ๋กค์์ด ์คํ์ผ ํ์ ํ์๋์ด์ผ <head>
. ๋๋จธ์ง ์คํ์ผ ์ํธ๋ <div id="__next">
์์๋ฅผ ํ์ํ์ฌ๋ก๋ ํ ์ ์์ต๋๋ค.
ํด๋น๋๋ ๊ฒฝ์ฐ ๋ฌธ์ ๋ฅผ ์ค๋ช ํ๋ ๋ฐ ๋์์ด๋๋ ์คํฌ๋ฆฐ ์ท์ ์ถ๊ฐํฉ๋๋ค.
๊ฐ๋ฐ ์๋ฒ์์ ๋ณผ ์์๋ FOUC๋ฅผ ํ์ธํ์ธ์.
ํ๋ก๋์ ์น ์ฌ์ดํธ์ ํ์๋ฉ๋๋ค .
CSS ๋ชจ๋์ ์ฌ์ฉํ ๋๋์ด ๋ฌธ์ ์ ์ง๋ฉดํ์ง๋ง styled-jsx๋ฅผ ์ฌ์ฉํ๋ฉด ์ ๋๋ก ์๋ํฉ๋๋ค.
_app.js์ ์ ์ญ CSS๊ฐ ๊ฐ๋ฐ ๋ชจ๋์์๋ ๋์ ์๋ฐ ์คํฌ๋ฆฝํธ๊ฐ ๊บผ์ง ์ํ๋ก๋ก๋๋์ง ์๋ ๊ฒ ๊ฐ์ ์ ์ฌํ ๋ฌธ์ ๋ฅผ ๋ฐ๊ฒฌํ์ต๋๋ค. ๋๋ฝ ๋ ์คํ์ผ์ด์์ ์ ์์ผ๋ฏ๋ก SSR์ ํ ์คํธํ๊ธฐ๊ฐ ๋ ์ด๋ ต์ต๋๋ค.
@robgraeber ๋๋ ๋น์ ์ดํ๋ ์ ํํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. CSS๋ ๋ณ๋์ css ํ์ผ ๋์ _app.js๋ก ์ปดํ์ผ๋ฉ๋๋ค.
์ฌ๊ธฐ์๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ์ฌํํ๋ ์ต์ ์์ ๋ฅผ ๋ง๋ค์์ต๋๋ค : https://github.com/dnaranjo89/next-css-ssr
๋ํ ๋๋ก๋ ๊ด๋ฆฌ์์์ ์ผ๋ถ ์ ์ญ CSS๋ฅผ ํธ์งํ๊ณ ๋ณ๊ฒฝํ๋ฉด ์ ์ฒด ํ์ด์ง์ CSS๊ฐ ์ด๋ป๊ฒ ๋ ์์๋ฉ๋๋ค. ๊ฒฝํ ํ ์ฌ๋ ์๋์?
@derskeal ํด๊ฒฐ ๋ฐฉ๋ฒ์์ด sass ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํ๊ณ ๋ ์ด์์ ๊ตฌ์ฑ ์์์์ sass๋ฅผ ํตํด ์คํ์ผ ์ํธ๋ฅผ ๊ฐ์ ธ ์ค๋ ๊ฒ์ ๋๋ค. https://github.com/giuseppeg/styled-jsx-plugin-sass
@Timer ๋๋์ด repo https://github.com/yanv1991/demo-react-dom ์์์ด ๋ฌธ์ ๋ฅผ ์ฌํ ํ ์
์ด ํ๋ก์ ํธ๋ ์คํํ ์ ์์ต๋๋ค :
error - Error [FirebaseError]: projectId must be a string in FirebaseApp.options
at new FirestoreError (/Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/firestore/dist/index.node.cjs.js:1223:28)
at Function.Firestore.databaseIdFromApp (/Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/firestore/dist/index.node.cjs.js:21018:19)
at new Firestore (/Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/firestore/dist/index.node.cjs.js:20850:42)
at /Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/firestore/dist/index.node.cjs.js:22871:66
at Component.instanceFactory (/Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/firestore/dist/index.node.cjs.js:22410:16)
at Provider.getOrInitializeService (/Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/component/dist/index.cjs.js:219:39)
at Provider.getImmediate (/Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/component/dist/index.cjs.js:120:33)
at FirebaseAppImpl._getService (/Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/app/dist/index.node.cjs.js:228:49)
at FirebaseAppImpl.firebaseAppImpl.<computed> [as firestore] (/Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/app/dist/index.node.cjs.js:440:39)
at Object.serviceNamespace [as firestore] (/Users/joe/Desktop/scratch2/covid-tutoring/node_modules/@firebase/app/dist/index.node.cjs.js:420:45)
at eval (webpack-internal:///./src/firebase/db.tsx:19:124)
at Module../src/firebase/db.tsx (/Users/joe/Desktop/scratch2/covid-tutoring/.next/server/static/development/pages/_app.js:128:1)
at __webpack_require__ (/Users/joe/Desktop/scratch2/covid-tutoring/.next/server/static/development/pages/_app.js:23:31)
at eval (webpack-internal:///./src/firebase/user.tsx:12:61)
at Module../src/firebase/user.tsx (/Users/joe/Desktop/scratch2/covid-tutoring/.next/server/static/development/pages/_app.js:152:1)
at __webpack_require__ (/Users/joe/Desktop/scratch2/covid-tutoring/.next/server/static/development/pages/_app.js:23:31) {
code: 'invalid-argument',
toString: [Function]
}
์ด๊ฒ์ next@^9.4.5-canary.15
์์ ์์ ๋์ด์ผํฉ๋๋ค! ์
๊ทธ๋ ์ด๋ํ์ฌ ์๋ ค์ฃผ์ญ์์ค.
@Timer ๊ฐ์ฌํฉ๋๋ค! ๐ ํ ์คํธ๋ฅผํ๊ณ ์์ ์ฌํญ์ด ํจ๊ณผ๊ฐ ์์ต๋๋ค.
์ปค์คํ
์๋ฒ (์ํฐํ๋ผ์ด์ฆ ์ฌ์ดํธ์์ ์ ์ง์ ์ผ๋ก ํ์ด์ง ๋ณํ)์ ๊ฐ๋ฐ ๋ชจ๋์ ํ๋ก๋์
๋ชจ๋์์์ด ๋ฌธ์ ๋ฅผ ๊ฒฝํํ์ต๋๋ค. ^9.4.5-canary.15
์์ ํ์ต๋๋ค!
์๋ ํ์ธ์. ์นด๋๋ฆฌ์ ๋ฆด๋ฆฌ์ค์ ๋ฌธ์ ๋ฅผ ํ์ธํ๊ณ ๊ฐ๋ฐ ๋ชจ๋์์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง๋ง ํ๋ก๋์ ์์๋ ์ฌ์ ํ ๋ฌธ์ ๊ฐ ๋จ์ ์์ต๋๋ค. ๋๊ตฐ๊ฐ๊ฐ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฒฝํํฉ๋๊น?
ํ๋ก๋์
๋น๋์๋ <style data-next-hide-fouc="true">body{display:none}</style>
.
์๋ ํ์ธ์. ์นด๋๋ฆฌ์ ๋ฆด๋ฆฌ์ค์ ๋ฌธ์ ๋ฅผ ํ์ธํ๊ณ ๊ฐ๋ฐ ๋ชจ๋์์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง๋ง ํ๋ก๋์ ์์๋ ์ฌ์ ํ ๋ฌธ์ ๊ฐ ๋จ์ ์์ต๋๋ค. ๋๊ตฐ๊ฐ๊ฐ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฒฝํํฉ๋๊น?
ํ๋ก๋์ ๋น๋์๋
<style data-next-hide-fouc="true">body{display:none}</style>
.
์ฌ๊ธฐ์์ ๋๊ฐ์ต๋๋ค. ์ด๊ฒ์ ์ฐ๋ฅด๊ธฐ ๋๋ ๊ด๋ จ์์ ๋ฐ์ํ ๋ ๋ค๋ฅธ ๋ฌธ์ ์ ๋๊น? ๋๊ตฌ๋ ์ง ์๊ณ ์์ต๋๊น?
์ฌ๊ธฐ์์ ๋๊ฐ์ต๋๋ค. ์ด๊ฒ์ ์ฐ๋ฅด๊ธฐ ๋๋ ๊ด๋ จ์์ ๋ฐ์ํ ๋ ๋ค๋ฅธ ๋ฌธ์ ์ ๋๊น? ๋๊ตฌ๋ ์ง ์๊ณ ์์ต๋๊น?
๋์๊ฒ์ด ๋ฌธ์ ๋ ํ๋ก๋์ ๋ชจ๋๊ฐ ์๋ ๊ฐ๋ฐ ๋ชจ๋์์๋ง ๋ฐ์ํ์ต๋๋ค. ๋ฐ๋ผ์ ๋๋ prod ๋ฌธ์ ๊ฐ ๋ค๋ฅธ ์์ธ์ ๊ฐ์ง ์ ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
์๋ ํ์ธ์. ์นด๋๋ฆฌ์ ๋ฆด๋ฆฌ์ค์ ๋ฌธ์ ๋ฅผ ํ์ธํ๊ณ ๊ฐ๋ฐ ๋ชจ๋์์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง๋ง ํ๋ก๋์ ์์๋ ์ฌ์ ํ ๋ฌธ์ ๊ฐ ๋จ์ ์์ต๋๋ค. ๋๊ตฐ๊ฐ๊ฐ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฒฝํํฉ๋๊น?
ํ๋ก๋์ ๋น๋์๋
<style data-next-hide-fouc="true">body{display:none}</style>
.
ํ๋ก๋์ ์์์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์์๋ ์ฌ๋์ด ์์ต๋๊น? Canary ๋ฆด๋ฆฌ์ค๋ ๊ฐ๋ฐ ๋น๋๋ฅผ ์์ ํ์ง๋ง ํ๋ก๋์ ์ ์ฌ์ ํ โโ์ค๋จ๋์์ต๋๋ค.
๊ทธ๋ผ ๋ค์ ์นด๋๋ฆฌ์ ์ต์ ๋ฒ์ ์ธ๊ฐ์?
์ @jimmynames , canary๋ WIP ์ต์ ๋ฒ์ ์ ๋๋ค (์ด ์ฉ์ด๋ ์นด๋๋ฆฌ์ ์๋ฅผ ์ฌ์ฉํ์ฌ ๋ ์ฑ ์ฐ๊ธฐ๋ฅผ ํ ์คํธํ๋ ๊ด๋ถ์์ ์ ๋ํ์ต๋๋ค ... Next.js์ ์นด๋๋ฆฌ์ ๋ฒ์ ์ ์ค์ผ์น๊ฐ ๋ ์ ์์ต๋๋ค).
์ด ์์ ์ฌํญ์ Next.js 9.5.0 ๋ฐ 9.5.1 ์ด์์ ์์ ์ ์ธ ๋ฆด๋ฆฌ์ค์ ์์ต๋๋ค (๊ฐ๋ฐ ์๋ฒ์๋ง ์ ์ฉ๋จ)!
์์ฐ์ ์ด๋ป์ต๋๊น? ๋๋ ์ฌ์ ํ StyledComponents + Material UI๋ก FOUC๋ฅผ ๊ฒฝํํ๊ณ ์์ต๋๋ค.
์๋ฌด๋ ์ด๊ฒ์ ๋ํ ํด๊ฒฐ์ฑ ์ ์ฐพ์์ต๋๊น?
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์์ฐ์ ์ด๋ป์ต๋๊น? ๋๋ ์ฌ์ ํ StyledComponents + Material UI๋ก FOUC๋ฅผ ๊ฒฝํํ๊ณ ์์ต๋๋ค.