JSX & babel

Suyeon Leeยท2023๋…„ 12์›” 17์ผ
0

[React] ์‹œ์ž‘ํ•˜๊ธฐ

๋ชฉ๋ก ๋ณด๊ธฐ
4/19
post-thumbnail
post-custom-banner

๐Ÿ“Œ babel

JSX ๋ฌธ๋ฒ•์œผ๋กœ ์ž‘์„ฑ๋œ ์ฝ”๋“œ๋ฅผ ์ˆœ์ˆ˜ํ•œ JavaScript๋กœ ์ปดํŒŒ์ผํ•˜์—ฌ ์‚ฌ์šฉ

https://babeljs.io/setup#installation

<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babwel"></script>
<script type="text/babel">
    console.log(React);
    console.log(ReactDOM);

    ReactDOM.render(
    <div>
      <div>
        <h1>์ฃผ์ œ</h1>
        <ul>
          <li>React</li>
          <li>Vue</li>
          </ul>
      </div>
    </div>,
    document.querySelector('#root')
    )

JSX ๋ฌธ๋ฒ•

  • ์ตœ์ƒ์œ„ ์š”์†Œ๊ฐ€ ํ•˜๋‚˜์—ฌ์•ผ ํ•จ
  • ์ตœ์ƒ์œ„ ์š”์†Œ ๋ฆฌํ„ดํ•˜๋Š” ๊ฒฝ์šฐ, ()๋กœ ๊ฐ์‹ธ์•ผ ํ•จ
  • ์ž์‹๋“ค์„ ๋ฐ”๋กœ ๋ Œ๋”๋งํ•˜๊ณ  ์‹ถ์œผ๋ฉด, <>์ž์‹๋“ค</> ์‚ฌ์šฉ โ‡’ Fragment
  • ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํ‘œํ˜„์‹์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด, {ํ‘œํ˜„์‹} ์ด์šฉ
  • if ๋ฌธ ์‚ฌ์šฉ ๋ถˆ๊ฐ€๋Šฅ
    • ์‚ผํ•ญ ์—ฐ์‚ฐ์ž or && ์‚ฌ์šฉ
  • style์„ ์ด์šฉํ•ด ์ธ๋ผ์ธ ์Šคํƒ€์ผ๋ง์ด ๊ฐ€๋Šฅ
  • class ๋Œ€์‹  className์„ ์‚ฌ์šฉํ•ด class๋ฅผ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Œ
  • ์ž์‹ ์š”์†Œ๊ฐ€ ์žˆ์œผ๋ฉด ๊ผญ ๋‹ซ์•„์•ผ ํ•˜๊ณ , ์ž์‹ ์š”์†Œ๊ฐ€ ์—†์œผ๋ฉด ์—ด๋ฉด์„œ ๋‹ซ์•„์•ผ ํ•จ
    - <p>Hello</p>, <br />
profile
๋งค์ผ ๋ Œ๋”๋งํ•˜๋Š” FE ๊ฐœ๋ฐœ์ž
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€