From 9bd48005fda1d94a526e36bec256b56add65b28d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 28 Oct 2022 00:23:40 +0300 Subject: use `react-hook-form` and fix tests --- vnext/src/ui/Login.js | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'vnext/src/ui/Login.js') diff --git a/vnext/src/ui/Login.js b/vnext/src/ui/Login.js index 774664c0..fc3922c8 100644 --- a/vnext/src/ui/Login.js +++ b/vnext/src/ui/Login.js @@ -3,8 +3,7 @@ import { useLocation, useHistory } from 'react-router-dom'; import Icon from './Icon'; import Button from './Button'; -import Input from './Input'; -import { useFormState } from 'react-use-form-state'; +import { useForm } from 'react-hook-form'; import { me, facebookLink, vkLink, appleLink } from '../api'; @@ -33,14 +32,11 @@ function Login({ visitor, onAuth }) { } }, [history, location.state, visitor]); - const [formState, { text, password }] = useFormState(); + const { register, handleSubmit, formState: { errors }, } = useForm(); - /** - * @param {React.SyntheticEvent} event - */ - let onSubmit = (event) => { - event.preventDefault(); - me(formState.values.username, formState.values.password) + /** @type { import('react-hook-form').SubmitHandler } */ + let onSubmit = (values) => { + me(values.username, values.password) .then(response => { onAuth(response); } @@ -63,14 +59,10 @@ function Login({ visitor, onAuth }) {

Already registered?

-
-
-
- + +
+
+
-- cgit v1.2.3