Last active
December 28, 2019 15:41
-
-
Save hjumeau/4eabdc745e588718dd8ee125d62efd72 to your computer and use it in GitHub Desktop.
A basic login form react redux-form typescript
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 { Field, reduxForm } from "redux-form"; | |
const LoginComponent = ({errorMessage, handleSubmit}) => { | |
return ( | |
<form onSubmit={handleSubmit}> | |
<div> | |
<label htmlFor="username">USERNAME</label> | |
<Field id="username" name="username" component="input" type="text" /> | |
</div> | |
<div> | |
<label htmlFor="password">PASSWORD</label> | |
<Field id="password" name="password" component="input" type="password" /> | |
</div> | |
<button id="sign-in-submit" style={{marginTop: 40}} type="submit">Connexion</button> | |
{!!errorMessage && <p style={{color: "red"}}>{errorMessage}</p>} | |
</form> | |
); | |
}; | |
export const LoginForm = reduxForm({ form: "signin" })(LoginComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment