๋ฐ์ํ
App.js
import React from "react";
import Wrapper from "./component/Wrapper";
import Hello from "./component/Hello";
import "./App.css";
function App() {
/* ๊ฐ์ฒดํ์ผ๋ก ํ์ฌ ์ปดํฌ๋ํธ์์ ์คํ์ผ์ ์ ์ธํ๋ ๋ฐฉ๋ฒ */
const style = {
backgroundColor: "skyblue",
color: "white",
fontSize: 40,
padding: "1rem",
};
const name = "hello2";
return (
<>
{/* css๋ฅผ ์ ์ฉํ๋ ๋ฐฉ๋ฒ : className ์์ฑ์ ์ ์ฉ */}
{/*
์ปดํฌ๋ํธ์์ ํ๊ทธ๋ฅผ ์ถ๊ฐ ํ ์ ์๋ค ๊ทธ๋๋ ํ ์ ์๋ค
๋ฐฉ๋ฒ์ ๋งค๊ฐ๋ณ์ ์ปดํฌ๋ํธ์์ { children } ๊ฐ์ฒด๋ฅผ ๋งค๊ฐ๋ณ์ ์ ๋ฌํ๊ณ
return ์์ชฝ์ { children } ๋ฅผ ์ ์ธํ๋ฉด
์ปดํฌ๋ํธ ์์ ์ด๋ ์ํด๋ ํ๊ทธ๋ฅผ ์
๋ ฅํ ์ ์๋ค
*/}
<Wrapper />
<Wrapper>
<div className="deeppink">hello1</div>
<div style={style}>{name}</div>
<Hello name="apple" color="gold" isSpecial={true} />
<Hello name="banana" color="yellowgreen" />
<Hello/>
</Wrapper>
</>
);
}
export default App;
์ด๋ฐ์์ผ๋ก style์ด๋ผ๋ ์คํ์ผ์ const ํจ์๋ก ๋ง๋ค์ด์
<div style={style}>์ผ๋ก ์ ์ฉํจ
๋ฐ์ํ