React.js
๋ฅผ ์ด์ฉํ ์ธ์คํ๊ทธ๋จ ํด๋ก CRA(create-react-app)
๋ฅผ ์ฌ์ฉํ ์ด๊ธฐ ์ธํ
Git
์ ์ฌ์ฉํ ํ ํ์
๊ณผ์ MockData
๋ฅผ ์ด์ฉํ์ฌ UI ๊ตฌํ ํ componentDidMount()
์ fetch()
๋ฅผ ์ด์ฉํด ๋ฐฑ์๋์์ ํต์ React
JavaScript
SASS
Git
ย ย ๋ก๊ทธ์ธ ํ์ด์ง
fade-in / fade out
withRouterHOC
๋ก ํ์ด์ง ์ด๋ ๊ตฌํ - this.props.history.push('/signup')
fetch()
MockData
์ map()
์ ํ์ฉํด sitemap ๊ตฌํย ย ๋ฉ์ธ ํ์ด์ง
Mockdata
์ map()
์ ํ์ฉํ์ฌ ์ปดํฌ๋ํธ ํ์ฉ constructor() {
super();
this.state = {
isChecked: false,
id: '',
password: '',
};
}
goToMain = () => {
const { isChecked, id, password } = this.state;
isChecked &&
fetch('http://3.34.133.239:8000/account/signin', {
method: 'POST',
body: JSON.stringify({
email: id,
password: password,
}),
})
.then((response) => response.json())
.then((result) => {
if (result.Authorization) {
localStorage.setItem('token', result.Authorization);
this.props.history.push('/main-wontae');
} else if (result.message === 'UNAUTHORIZED') {
alert('์ด๋ฉ์ผ / ๋น๋ฐ๋ฒํธ๋ฅผ ํ์ธํด์ฃผ์ธ์');
}
});
};
saveData = (e) => {
const { name, value } = e.target;
this.setState(
{
[name]: value,
},
this.checkValidation
);
if (e.key === 'Enter') {
this.goToMain();
}
};
checkValidation = () => {
const { id, password } = this.state;
const isChecked = id.includes('@') && password.length >= 5;
this.setState({
isChecked,
});
};
render() {
retrun (
...
<div onKeyUp={this.saveData} className="form">
<input
name="id"
type="text"
placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
/>
<input name="password" type="password" placeholder="๋น๋ฐ๋ฒํธ" />
<button
type="submit"
className={isChecked ? 'isActive' : null}
onClick={this.goToMain}
>
๋ก๊ทธ์ธ
</button>
</div>
...
)
}
fetch()
ํจ์๋ก ์๋ฒ์์ ๋ฐ์ดํฐ ํต์ className
์ ๋์ ์ธ ์ฌ์ฉInput
์ name๊ณผ ๊ณ์ฐ๋ ์์ฑ๋ช
(computed property names)
์ด์ฉํ๊ธฐ