Created
November 24, 2018 05:25
-
-
Save Joe1220/4cb298f4c3137621cff806b3aee897e4 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, inject } from 'mobx-react' | |
import "./Login.css" | |
@inject("testStore") | |
@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> | |
<p>현재 유저 목록</p> | |
{this.props.testStore.userList.map((user, index) => { | |
return ( | |
<div> | |
<p>이름: {user.email}</p> | |
</div> | |
) | |
})} | |
</div> | |
</div> | |
); | |
} | |
@action.bound | |
onChange(event) { | |
const { name, value } = event.target; | |
this[name] = value; | |
} | |
onSubmit() { | |
const { email, password } = this | |
this.props.testStore.addUser({ email, password }) | |
} | |
} | |
export default Login; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment