Last active
July 5, 2019 15:15
-
-
Save arminyahya/6ac6148816eaf147bb37f2e1c0aa7c43 to your computer and use it in GitHub Desktop.
final form
This file contains 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 from 'react'; | |
import LoginFormState from './formstate'; | |
import { useInstance } from './hooks'; | |
import { Observer } from 'mobx-react'; | |
const LoginForm = () => { | |
const formData = useInstance(() => new LoginFormState()); | |
return ( | |
<Observer> | |
{() => { | |
return ( | |
<div className="login-form"> | |
<div className="login-form_field"> | |
<label>username</label> | |
<input onChange={(e) => { formData.username.onChange(e.target.value); }} /> | |
</div> | |
<div className="login-form_field"> | |
<label>password</label> | |
<input onChange={(e) => { formData.password.onChange(e.target.value); }} /> | |
</div> | |
<button type="button" onClick={formData.onSubmit}>submit</button> | |
</div>) | |
}} | |
</Observer> | |
); | |
} | |
export default LoginForm; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment