[React] State와 Props
·
🔵 React
import './App.css';import { useState } from 'react';const Bulb = ({ light }) => { return ( {light === 'ON' ? ( ON ) : ( OFF )} );};function App() { // state 생성 // 기본 구조: const [state, setState] = useState(0); const [count, setCount] = useState(0); // 2. lightState의 값을 on으로 바꾸면 전구가 렌더링된다. const [light, setLight] = useState('OFF'); return ( ..