import React from "react";
// props를 통해 부모 -> 자식 데이터가 전달됐다.
function Son(props) {
console.log("props", props);
return <div>나는 {props.motherName}의 아들이에요!</div>;
}
// 부모 -> 자식 정보를 전달했다!
function Mother() {
const name = '흥부인';
return <Son motherName={name}/>;
}
function GrandFather() {
return <Mother />;
}
function App() {
return <GrandFather />;
}
export default App;
import React, { useState } from "react";
import "./App.css";
function App() {
const [id, setId] = useState("");
const [password, setPassword] = useState("");
function logIn() {
alert(
"고객님이 입력하신 아이디는" +
id +
"이며, 비밀번호는" +
password +
"입니다."
);
setId("");
setPassword("");
}
return (
<div>
아이디 :{" "}
<input
type="text"
value={id}
onChange={function (event) {
setId(event.target.value);
}}
/>
<br />
비밀번호 :{" "}
<input
type="password"
value={password}
onChange={function (event) {
setPassword(event.target.value);
}}
/>
<br />
<button onClick={logIn}>로그인</button>
</div>
);
}
export default App;
Something is already running on port 3000.
yarn start 했는데 3000 포트가 사용중이라는 에러가 떴다.
netstat -ano 명령어로 사용중인 포트를 조회해서 PID 확인 후 작업관리자에서 PID 검색으로 사용중인 프로그램을 봤더니 Node.js 였다. 나도 node로 써야하니까 그냥 작업을 끝내버리고 다시 yarn start 했더니 정상작동 되었다.
리액트도 화이팅!