๐ก JavaScript XML์ ์ค์๋ง
๐ก React์์ UI๋ฅผ ๊ตฌ์ฑํ ๋ ์ฌ์ฉํ๋ JavaScript๋ฅผ ํ์ฅํ ๋ฌธ๋ฒ
JSX -> bable๋ก ์ปดํ์ผ -> JavaScript๋ก ๋ณํ -> ๋ธ๋ผ์ฐ์ ์์ ๋ ๋๋ง
๐ JSX์์ด ๊ตฌํํ๊ธฐ
function App(){
return React.createElement("h1", null, "Hello, world")
}
๐ JSX๋ก ๊ตฌํํ๊ธฐ
function App(){
return <h1>Hello, world</h1>
}
๐ ์ ์ฒด๋ฅผ ๊ฐ์ธ์ฃผ๋ ์๋ฆฌ๋จผํธ ํ์
function App(){
return (
//ERROR!!
//<div>a</div>
//<div>b</div>
<div>
<div>a</div>
<div>b</div>
</div>
)
}
๐ ๋ฐฐ์ด ๋ฐํ์ ๊ฐ๋ฅ
function App(){
return (
[<div>a</div>, <div>b</div>]
)
}
๐ ํํ์์ ๊ฒฝ์ฐ {} ์ฌ์ฉ
function App(){
const func = () => {
return <p>a</p>;
}
return (
<span onClick={func}></span>
);
}
๐ ํํ์์ด๋ผ๋ ํจ์ ์์ฒด ํธ์ถ์
function App(){
const func = () => {
return <p>a</p>;
}
return (
<div>{func()}</div>
);
}
๐ ์ผํญ์ฐ์ฐ์๋ ํํ์
const a = <div>{(1 + 1 === 2) ? (<p>true</p>) : (<p>false</p>)}</div>