리액트 실행흐름

공부는 혼자하는 거·2021년 5월 1일
0

복습할 겸 다시 적어본다.

package.json : 리액트 설정파일
여기서 index.js를 실행

import React from 'react'; //index.js
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

ReactDOM.render(
  <React.StrictMode>//React.StrictMode : 문법검사도구 - APP 파일이 정상적으로 실행되는지 한 번 더 검사
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

index.js가 순차적으로 실행되면서 render라는 함수를 실행
render는 APP을 document.getElementById('root') 여기에다 실행하는데, root가 어디에 있냐면 public이라는 폴더 안에 index.html 안에 있다.

  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>

  </body>
</html>


사진 출처:https://newline.tistory.com/117

https://www.holaxprogramming.com/2017/12/21/node-yarn-tutorials/ yarn 돌아보기

profile
시간대비효율

0개의 댓글