Skip to content

Instantly share code, notes, and snippets.

@Joe1220
Created November 24, 2018 04:44
Show Gist options
  • Save Joe1220/f27c10abad5eb8082072ef069d0ca963 to your computer and use it in GitHub Desktop.
Save Joe1220/f27c10abad5eb8082072ef069d0ca963 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { observable, action } from 'mobx'
import { observer } from 'mobx-react'
import "./Login.css"
@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