_app.js

export default function App({Component, pageProps}){
	return <Component {...pageProps}/>;
}
export default App;

- _app.js에서 rendering하는 값은 모든 page에 영향을 준다. 때문에 전역 css를 적용하거나 할 때 사용된다.

- 내부에 Component가 있으면 전부 실행하고 html의 body로 구성된다. 

- Component와 pageProps를 받는데, 이 때 props로 받은 Component는 요청한 page이다. 

- GET/ 요청을 보냈다면, Component에는 /pages/index.js file이 props로 오게되고, pageProps는 page getInitialProps를 통해 내려 받은 props들을 말한다. 그 다음 _document.tsx가 실행된다. 

 

! global CSS file은 오직 pages/_app.js에서만 import 할 수 있다. 

 

[ + ] 

getInitialProps 는 다음에 알아봐야지.

 

 

 

https://nextjs.org/learn/basics/assets-metadata-css/global-styles

https://kyounghwan01.github.io/blog/React/next/basic/#app-tsx

728x90

'Framework\Library > React' 카테고리의 다른 글

[ React : CRA ] create-react-app ( CRA ) 시작  (0) 2021.12.10
[ React : Next.js ] Pages  (0) 2021.11.23
[ React ] Next.js : React Framework + <Link>, CSN  (0) 2021.11.23
[ React ] React Framework  (0) 2021.11.23
[ React ] Hook - state  (0) 2021.11.22

+ Recent posts