Last active
November 24, 2018 03:57
-
-
Save Joe1220/dcb550a7395f8cb3fea5dd2c4f3f993a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { observable, action } from 'mobx' | |
import { observer } from 'mobx-react' | |
@observer | |
class Login extends Component { | |
@observable email = '' | |
@observable passwords = '' | |
constructor(props) { | |
super(props) | |
this.onSubmit = this.onSubmit.bind(this) | |
} | |
render() { | |
const { email, password } = this | |
return ( | |
<div className="App"> | |
<header>Login</header> | |
<input name="email" placeholder="Email" onChange={this.onChange} value={email} fluid /> | |
<input | |
name="password" | |
type="password" | |
placeholder="Password" | |
onChange={this.onChange} | |
value={password} | |
fluid | |
/> | |
<button onClick={this.onSubmit}>Submit</button> | |
</div> | |
); | |
} | |
@action.bound | |
onChange(event) { | |
const { name, value } = event.target; | |
this[name] = value; | |
} | |
onSubmit() { | |
const { email, password } = this | |
console.log('결과확인 : ', email, password); | |
} | |
} | |
export default Login; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment