- Component : React 페이지 구성하는 최소 단위
- Element : 컴포넌트의 구성 요소
- Props : 데이터
- State : View
1) Import the React and ReactDOM libraries
2) Get a reference to the div with ID root
3) Tell React to take control of that element
4) Create a component
5) Show the component on the screen
function App() {
let message = "Bye there!";
if (Math.random() > 0.5) {
message = "Hello there!";
}
return <h1>{message}</h1>;
}
function App() {
const config = {color : 'red'};
return (
<div>
<h1>{config}</h1> // (1)
<input abc={config} /> // (2)
</div>
);
}
function App() {
const message = "Enter Age";
return (
<input
type="number"
min={5}
max={10}
list={[1, 2, 3]}
// Arrays : Wrap with curly braces
style={{ color: "red" }}
// Objects : Wrap with curly braces
alt={message}
// Variables : Wrap with curly braces
/>
);
}