reactform

1.0.81 • Public • Published
Example login component.
import React, { Component } from 'react';
import { Redirect } from 'react-router-dom';
import { Form, TextInput, PasswordInput, Submit } from 'reactform';
import { login } from '../../lib/auth.js';
 
export default class Login extends Component {
 
    constructor(props) {
        super(props);
        this.state = {
            success: false
        };
    }
 
    login = ({ username, password }) => {
        login(username, password, (err, res) => {
            if (res.ok) {
                this.setState({ success: true });
            }
        });
    };
 
    render() {
        const { success } = this.state;
 
        if (success) {
            return <Redirect to='/' />;
        }
 
        return (
            <Form onSubmit={this.login}>
                <TextInput required name='username' placeholder='username' validator={'alphanumeric'} />
                <PasswordInput required name='password' placeholder='password' validator={'alphanumeric'} />
                <Submit />
            </Form>
        );
    }
 
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.816latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.816
1.0.800
1.0.790
1.0.780
1.0.770
1.0.760
1.0.750
1.0.740
1.0.721
1.0.710
1.0.700
1.0.690
1.0.680
1.0.660
1.0.650
1.0.640
1.0.630
1.0.620
1.0.610
1.0.600
1.0.590
1.0.580
1.0.570
1.0.560
1.0.550
1.0.540
1.0.530
1.0.520
1.0.510
1.0.501
1.0.490
1.0.480
1.0.470
1.0.460
1.0.450
1.0.440
1.0.430
1.0.420
1.0.410
1.0.400
1.0.390
1.0.380
1.0.370
1.0.360
1.0.350
1.0.340
1.0.330
1.0.320
1.0.310
1.0.300
1.0.290
1.0.280
1.0.270
1.0.260
1.0.250
1.0.240
1.0.230
1.0.220
1.0.210
1.0.200
1.0.190
1.0.180
1.0.170
1.0.160
1.0.150
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i reactform

Weekly Downloads

4

Version

1.0.81

License

MIT

Last publish

Collaborators

  • ergusto