0.0.2 • Published 5 years ago

@riccoski/react-use-form v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

react-use-form

Install

yarn add --save @riccoski/react-use-form

Usage

import React from "react";
import useForm from "react-use-form";
import * as yup from "yup";

function App() {
  const { handleChange, handleSubmit } = useForm({
    onSubmit(values) {
      console.log("values", values);
    },
    validationSchema: yup.object().shape({
      password: yup.string().required(),
      email: yup
        .string()
        .email()
        .required()
    })
  });

  return (
    <form onSubmit={handleSubmit}>
      <label>Email address</label>
      <input
        onChange={handleChange}
        name="email"
        type="email"
        placeholder="Enter email"
      />
      <label>Password</label>
      <input
        onChange={handleChange}
        type="password"
        name="password"
        placeholder="Password"
      />
      <button type="submit">Log in</button>
    </form>
  );
}

export default App;

License

MIT © riccoski

0.0.2

5 years ago