[React] React JSX
JSX ๋ฌธ๋ฒ ์ ๋ฆฌ
import logo from './logo.svg';
import './App.css';
function App() {
const name = '์น๋ฏผ';
const list = ['์ฐ์ ', '๋ธ๊ธฐ', '๋ฐ๋๋'];
return (
<>
<h1 className='orange'>{`Hello! ${name}`}</h1>
<h2>Hellow!</h2>
<p>{name}</p>
<ul>
<li>์ฐ์ </li>
<li>๋ธ๊ธฐ</li>
<li>๋ฐ๋๋</li>
</ul>
<ul>
{list.map((item) => (
<li>{item}</li>
))}
</ul>
<img
style=
src='https://images.unsplash.com/photo-1667849006991-5b759790fcfb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHw1MXx8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60'
alt='nature'
/>
</>
);
}
export default App;
๊ตฌ์กฐ
- ํจ์๋ช ์ ๋๋ฌธ์๋ก ์์
- ๋ฐํ return์ ์ด๋ป๊ฒ UI๋ฅผ ํ๊ธฐํ ์ง JSX๋ฅผ return ํด์ฃผ์ด์ผ ํ๋ค.
JSX ๋ฌธ๋ฒ
- Component๋ ํ๋์ ํ๊ทธ๋ง ๋ฐํ ํด์ผํจ โ ๋ฐ๋ผ์ ๋ค์์ ํ๊ทธ๋ฅผ ๋ฐํํ๊ณ ์ถ๋ค๋ฉด ๋ถ๋ชจ ํ๊ทธ๋ก ๊ฐ์ธ์ฃผ์ด์ผ ํ๋ค.<></>
- ํ๊ทธ์ ํด๋์ค๋ฅผ ์ ์ฉํ ๋๋ className์ ์ฌ์ฉ
- HTML๋ถ๋ถ์ ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋๋ฅผ ์ฌ์ฉํ ๋๋ {} ์ค๊ดํธ ์ฌ์ฉ
Component ๋ง๋๋ ํ
- global.code-snippets.json.code-snippets ์ ํด๋น Snippet ์ ๋ ฅ
"reactFunction": {
"prefix": "rfc",
"body": "import React from 'react';\n\nexport default function ${1:${TM_FILENAME_BASE}}() {\n\treturn (\n\t\t<div>\n\t\t\t\n\t\t</div>\n\t);\n}\n\n",
"description": "Creates a React Function component"
},
"reactStatelessImplicitReturn": {
"prefix": "rsi",
"body": "import React from 'react';\n\nexport const ${1:${TM_FILENAME_BASE}} = (props) => (\n\t\t\t$0\n\t);",
"description": "Creates a React Function component"
}
- rfc ๋๋ rfi ์ ๋ ฅํ๋ฉด ์ปดํฌ๋ํธ ๊ตฌ์กฐ ์๋์์ฑ!
Leave a comment