1.    React๋กœ ํ™”๋ฉด ๊ฐœ๋ฐœ

์ž, ์ด์ œ๋ถ€ํ„ฐ REACT๋กœ ํ™”๋ฉด์„ ๊ฐœ๋ฐœ ํ•ด๋ณด์ž.

 

์•ž์—์„œ ์‚ฌ์ „ ์ค€๋น„์‹œ ํ”„๋กœ์ ํŠธ ํด๋”์ธ linkservice์•„๋ž˜์— npx create-react-app ์œผ๋กœ ์ด๋ฏธ client์„ ์ƒ์„ฑํ–ˆ๋‹ค.

#4. ํ”„๋กœ์ ํŠธ ํด๋” ๊ตฌ์กฐ ๋ฐ ํ™˜๊ฒฝ์„ค์ •

 

#4. ํ”„๋กœ์ ํŠธ ํด๋” ๊ตฌ์กฐ ๋ฐ ํ™˜๊ฒฝ์„ค์ •

1.1. ํ”„๋กœ์ ํŠธ ํด๋” ๊ตฌ์กฐ ๋ฐ ํ™˜๊ฒฝ์„ค์ • ํ”„๋กœ์ ํŠธ ํด๋” ๊ตฌ์กฐ๋Š” ํ”„๋ก ํŠธ์—”๋“œ์™€ ๋ฐฑ์—”๋“œ๋ฅผ ๋‚˜๋ˆ„๊ณ ์ž client / server๋กœ ๊ตฌ๋ถ„ ํ•œ๋‹ค. โŽฎํ”„๋กœ์ ํŠธ ํด๋” : linkserver/ |-------- client ( React ๊ตฌ์กฐ) |-------- server ( Python๊ตฌ

firstvalue.tistory.com

 

1.1.  React ๊ธฐ๋ณธ์„ค์ •

๊ธฐ๋ณธ ํด๋”๊ตฌ์กฐ์—์„œ ํ•„์š” ์—†๋Š” ํŒŒ์ผ์„ ๋ชจ๋‘ ์ง€์šด๋‹ค.

      · public ํด๋” ๋ฐ‘์— index.html์„ ์ œ์™ธํ•˜๊ณ  ๋ชจ๋‘ ์‚ญ์ œ

      · src ํด๋” ๋ฐ‘์— App.js, index.js ์„ ์ œ์™ธํ•˜๊ณ  ๋ชจ๋‘ ์‚ญ์ œ

React ํŒŒ์ผ ๊ตฌ์กฐ๋ฅผ ๊ฐ„๋‹จํžˆ ์„ค๋ช…ํ•œ๋‹ค๋ฉด,

1. index.js

src ํด๋”์— ๋ฉ”์ธ Script๋กœ ์—ฌ๊ธฐ์—์„œ HTML ํ…œํ”Œ๋ฆฟ ๋ฐ JavaScript์˜ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์กฐํ•ฉํ•˜์—ฌ ๋ Œ๋”๋ง์„ ํ•œ๋‹ค.

 

2. App.js

src ํด๋”์— ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ •์˜ํ•˜๋Š” Script์ด๋‹ค. ์‹ค์ œ๋กœ ํ™”๋ฉด์— ํ‘œ์‹œ๋˜๋Š” ๋‚ด์šฉ ๋“ฑ์€ ์—ฌ๊ธฐ์—์„œ ์ •์˜๋œ๋‹ค.

 

3. index.html

public ํด๋”์— ์žˆ์œผ๋ฉฐ, HTML ํ…œํ”Œ๋ฆฟ ํŒŒ์ผ์ด๋‹ค. ์ด ํŒŒ์ผ์ด ์ง์ ‘ ํ‘œ์‹œ๋˜๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๊ณ , index.js์— ์˜ํ•ด ๋ Œ๋”๋ง ๋œ ๊ฒฐ๊ณผ๊ฐ€ ํ‘œ์‹œ๋œ๋‹ค.

 

   ๐Ÿ“Œ App.js์—์„œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ •์˜ํ•˜๊ณ  -> index.js ์—์„œ ReactDOM.rendor ํ•˜๊ณ   -> index.html์—์„œ ํ‘œ์‹œ๋œ๋‹ค.

 

๋จผ์ €, App.js ์„ ์ˆ˜์ •ํ•œ๋‹ค.

์•„๋ž˜ ์ฝ”๋“œ์—์„œ ํ•„์š” ์—†๋Š” ๋‚ด์šฉ ์ง€์šฐ๊ณ , ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ถ”๊ฐ€ ํ•œ๋‹ค.

 


index.js ์—์„œ reportWebVitals ๋ถ€๋ถ„๊ณผ import index.css์„ ์ฃผ์„์ฒ˜๋ฆฌ ํ•œ๋‹ค.

   ๐Ÿ“Œ ์ฐธ๊ณ ๋กœ, reportWebVitals๋Š” Create React App์—์„œ ์„œ๋“œํŒŒํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ Index ํŒŒ์ผ์— ์จ ์žˆ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ

       reportWebVitals() ์— console.log์„ ๋„ฃ์–ด์ฃผ๋ฉด ๊ฐœ๋ฐœ์ฐฝ์„ ํ†ตํ•ด ์•ฑ์˜ ํผํฌ๋จผ์Šค ์‹œ๊ฐ„๋“ค์„ ๋ถ„์„ํ•˜์—ฌ objectํ˜•ํƒœ๋กœ

      ๋ณด์—ฌ์ค€๋‹ค.

 

 

์ด์   ํ„ฐ๋ฏธ๋„์—์„œ yarn start์„ ์‹คํ–‰ํ•˜๊ณ , ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ ‘์†ํ•ด๋ณด์ž.

1.2. ๋””์ž์ธ ๊ฐ€์ ธ์˜ค๊ธฐ

๋””์ž์ธ๊นŒ์ง€ ํ•˜๋ฉด 1์ธ ๊ฐœ๋ฐœ์ž๋กœ ๊ฐ€์žฅ ์ด์ƒ์ ์ด๋งŒ, ๊ทธ๋งŒํผ ๋งŽ์€ ๋…ธ๋ ฅ์ด ํ•„์š”ํ•˜๋‹ค. ๋‚˜๋„ ๋””์ž์ธ ๋งŒํผ์€ ๋งŽ์ด ๋ฐฐ์šฐ์ง€ ๋ชปํ•ด์„œ ์–•์€ ์ง€์‹์œผ๋กœ ํ™”๋ฉด์„ ๋งŒ๋“ค์–ด ๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค.

 

๋””์ž์ธ์ด ํ•„์š” ์—†๋Š” ๋ถ„๋“ค์€ ๋””์ž์ธ ์„ค๋ช…๋ถ€๋ถ„์„ ์ œ์™ธํ•˜๊ณ , ๊ฐœ๋ฐœ๋ถ€๋ถ„๋งŒ ๋ด๋„ ๋œ๋‹ค.

 

์šฐ์„  Bootstrap ๋ฌด๋ฃŒ ๋””์ž์ธ์„ ๊ฐ€์ง€๊ณ  ์™€์„œ ๋ณ€๊ฒฝํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค.

๋””์ž์ธ ์ฐธ์กฐ : https://getbootstrap.com/docs/5.3/examples/

์šฐ๋ฆฌ๋Š” Albumํ™”๋ฉด์„ ๊ฐ€์ง€๊ณ  ์‹œ์ž‘ํ•˜๊ณ ์ž ํ•œ๋‹ค. https://getbootstrap.com/docs/5.3/examples/album/ ์ ‘์†ํ›„ ์˜ค๋ฅธ์ชฝ ๋งˆ์šฐ์Šค ํด๋ฆญํ•ด์„œ ํŽ˜์ด์ง€ ์†Œ์Šค๋ณด๊ธฐ์—์„œ HTML์„ ๋ณต์‚ฌํ•˜์—ฌ index.html์— ๋ถ™์—ฌ ๋„ฃ๋Š”๋‹ค.

 

BootStrap ๋ฌด๋ฃŒ๋””์ž์ธ HTML์ฝ”๋“œ๋ฅผ index.html์— ๋ถ™ํžŒ๋‹ค.

 

Title๋“ฑ ํ…์ŠคํŠธ ๋ถ€๋ถ„์„ ๋นผ๊ฑฐ๋‚˜, ์ˆ˜์ •ํ•˜์‹œ๊ณ , HTML์—์„œ ๋ณธ๋ฌธ์— ํ•ด๋‹น๋˜๋Š” <main></main> ๊ณผ <footer></footer> ๋Š” ์‚ญ์ œํ•˜๊ณ  ๋‚˜๋จธ์ง€ ๋ถ€๋ถ„์—์„œ ํ•„์š”ํ•œ ๋ถ€๋ถ„์€ ์ถ”๊ฐ€/์ˆ˜์ •/์‚ญ์ œํ•ด์„œ ์ดˆ๊ธฐ ํ™”๋ฉด์„ ๊ตฌ์„ฑํ•ด๋ณด์ž

 

<main></main> ๋ถ€๋ถ„์ด ๊ฐ€์žฅ ์ค‘์š”ํ•˜๋ฏ€๋กœ, ์†Œ์Šค๋‚ด ํ™•์ธํ•˜๊ธฐ ๋ฐ”๋ž€๋‹ค.

 

<!doctype html>
<html lang="ko">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1">
  <meta name="description" content="">
  <meta name="generator" content="Hugo 0.88.1">
  <title>๋งํฌ์„œ๋น„์Šค</title>

  <!-- Bootstrap core CSS -->
  <link href="https://getbootstrap.kr/docs/5.1/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>

<body>
  <header>
    <div class="collapse bg-dark" id="navbarHeader">
      <div class="container">
        <div class="row">
          <div class="col-12">
            <h4 class="text-white">๋งํฌ์„œ๋น„์Šค</h4>
            <p class="text-muted">๊ฐœ๋ฐœ์€ ์—„์—ฐํžˆ ์กด์ค‘ ๋ฐ›์•„์•ผ ํ•  ๊ฐœ์ธ์˜ ์ฐฝ์ž‘๋ฌผ์ž…๋‹ˆ๋‹ค. 
            </p>
          </div>
        <div class="col-12">
          <h6 class="text-white">Developers</h4>
          <ul class="list-unstyled">
            <li class="text-muted">(์ฃผ)XXXXXXXX</li>
            <li class="text-muted">์‚ฌ์—…์ž๋ฒˆํ˜ธ:XXX-XX-xxxxx</li>
            <li class="text-muted">๋Œ€ํ‘œ์ „ํ™”:000-1111-2222</li>            
          </ul>
        </div>
      </div>

      </div>
    </div>
    <div class="navbar navbar-dark bg-dark shadow-sm">
      <div class="container">
        <a href="/" class="navbar-brand d-flex align-items-center">
          <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor"
            stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" class="me-2"
            viewBox="0 0 24 24">
            <path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z" />
            <circle cx="12" cy="13" r="4" />
          </svg>
          <strong>๋งํฌ์„œ๋น„์Šค</strong>
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarHeader"
          aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
      </div>
    </div>
  </header>


  <main>
    <!-- ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ -->
    <section class="container" id="section">
    </section>    

    <div class="album py-4 bg-light" >
      <div class="container" id="root">
            <!--   ์—ฌ๊ธฐ์— ๋ณธ๋ฌธ๋‚ด์šฉ์„  ์ฒ˜๋ฆฌ -->
      </div>
    </div>
  </main>
  <!-- <footer class="text-muted py-2" id="footer">
  </footer> -->
</body>
</html>

๐Ÿ“Œ ๋””์ž์ธ ๋ฐ ํผ๋ธ”๋ฆฌ์‹ฑ์ด ๊ฐ€๋Šฅํ•˜์‹  ๋ถ„๋“ค์€ ๊ฐ์ž ๋‹ค๋ฅธ ๋””์ž์ธ์œผ๋กœ ํ•ด๋„ ๋ฌด๋ฐฉํ•˜๋‹ค.

 

์ด์   ํ™”๋ฉด์ด ์ž˜ ์ถœ๋ ฅ๋˜๋Š”์ง€ ํ™•์ธ ํ•œ๋‹ค.


๋‹ค์ŒํŽธ์—๋Š” Component์ œ์ž‘์„ ํ•ด๋ณด์ž.

 

+ Recent posts