git: https://github.com/leeyulgok/3-Day-React
const App = () => {
const [counter, setCounter] = React.useState(0);
const onClick = () => {
setCounter((current) => current + 1);
}
return (
<div>
<h1>Total Clicks: {counter}</h1>
<button onClick={onClick}>Click me</button>
</div>
);
};
const Btn = props => {
return (
<button style={{backgroundColor: props.backgroundColor}}>{props.text}</button>
);
}
const App = () => {
return (
<div>
<Btn backgroundColor="red" text="클릭!"/>
<Btn backgroundColor="blue" text="클릭!"/>
</div>
)
};
useEffect(() => {
const timer = setInterval(() => {
setCount((count) => count + 1)
}, 1000);
return () => {
clearInterval(timer);
console.log('clean up!');
};
},[]);
{
"compilerOptions": {
"baseUrl": "src"
},
"includes": ["src"]
}
기존코드
import First from "./components/01";
절대경로 코드
import First from "components/01";
import React, { useState } from 'react';
const LoginForm = () => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const usernameHandler = (e) => {
setUsername(e.target.value);
};
const passwordHandler = (e) => {
setPassword(e.target.value);
};
const submitHandler = (e) => {
e.preventDefault();
if (username === 'admin' && password === 'password') {
alert('로그인 성공');
} else {
alert('로그인 실패');
}
};
return (
<form onSubmit={submitHandler}>
<div>
<label htmlFor="username">아이디</label>
<input
type="text"
id="username"
value={username}
onChange={usernameHandler}
/>
</div>
<div>
<label htmlFor="password">비밀번호</label>
<input
type="password"
id="password"
value={password}
onChange={passwordHandler}
/>
</div>
<button type="submit">로그인</button>
</form>
);
};
export default LoginForm;
- 꾸준히 기록하기.
- 복습 계속하기.
- 내 웹 페이지 만들어보기.
- 다양하게 못한 점.
- 응용하기.
본 후기는 유데미-스나이퍼팩토리 10주 완성 프로젝트캠프 학습 일지 후기로 작성 되었습니다.
#프로젝트캠프 #프로젝트캠프후기 #유데미 #스나이퍼팩토리 #웅진씽크빅 #인사이드아웃 #IT개발캠프 #개발자부트캠프 #리액트 #react #부트캠프 #리액트캠프