3. 리액트를 쓰는 이유

  1. 리액트의 장점:

    • 더 단순한 심상 모델 제공.
    • 복잡한 웹앱과 웹 사용자 인터페이스를 쉽게 구축.
  2. 데모 웹사이트 비교:

    • 리액트와 바닐라 자바스크립트로 각각 만든 두 웹앱.
    • 코드샌드박스를 사용하여 클라우드 기반 개발.
  3. 바닐라 자바스크립트 웹앱:

    • index.html에 주요 HTML 요소 포함.
    • index.js에서 UI 업데이트 및 클릭 리스너 구현.
  4. 리액트 웹앱:

    • index.html에는 거의 내용이 없음.
    • 리액트가 사용자 인터페이스 전체를 렌더링.
  5. 리액트의 작동 원리:

    • index.js에서 리액트 앱의 시작.
    • App.js에서 HTML과 자바스크립트 코드 결합.
    • 선언형 프로그래밍을 통한 UI 상태 정의.
  6. 리액트와 자바스크립트의 차이:

    • 리액트는 선언형, 자바스크립트는 명령형 프로그래밍.
    • 리액트는 코드가 짧고 깔끔하며, UI 업데이트를 자동으로 처리.
    • 바닐라 자바스크립트는 단계별로 명령을 정의해야 하고 복잡함.
index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Vanilla JavaScript</title>
    <meta charset="UTF-8" />
    <link rel="stylesheet" href="styles.css" />
    <script src="index.js" defer></script>
  </head>

  <body>
    <header>
      <img src="js-logo-xs.png" alt="JavaScript logo" />
      <div>
        <h1>Vanilla JavaScript</h1>
        <p>i.e., JavaScript without any (UI) framework or library</p>
      </div>
    </header>

    <div id="tabs">
      <menu>
        <button id="btn-why-react" class="active">Why React?</button>
        <button id="btn-core-features">Core Features</button>
        <button id="btn-resources">Related Resources</button>
      </menu>
      <div id="tab-content"></div>
    </div>
  </body>
</html>

index.html
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<meta name="theme-color" content="#000000">
	<!--
      manifest.json provides metadata used when your web app is added to the
      homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
    -->
	<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
	<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
	<!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
	<title>React App</title>
</head>

<body>
	<noscript>
		You need to enable JavaScript to run this app.
	</noscript>
	<div id="root"></div>
	<!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
</body>

</html>