Skip to content

Instantly share code, notes, and snippets.

@hjumeau
Last active December 28, 2019 15:41
Show Gist options
  • Save hjumeau/4eabdc745e588718dd8ee125d62efd72 to your computer and use it in GitHub Desktop.
Save hjumeau/4eabdc745e588718dd8ee125d62efd72 to your computer and use it in GitHub Desktop.
A basic login form react redux-form typescript
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