DEV Community

Suraj Sharma
Suraj Sharma

Posted on • Updated on

A Login Form built using React Hooks

Created a simple login form using React, Typescript and React Material UI featuring useReducer and useEffect hooks.

Login Form

A detailed article on How to build a React Login Form with Typescript and React hooks

Top comments (3)

Collapse
 
jrbell989 profile image
Jason Bell

I've found that when using multiple useState hooks, it becomes easier to move to useReducer, especially when conditions mutate multiple pieces of state. I think useState still works well in your example, but once you build a more complex login (with 2FA, requiring a new user to set a new password, etc), it can get messy quickly.

Collapse
 
fantasticsoul profile image
幻魂

you can also refactor your from with concent, it is worth doing.
here is 2 demos:
js ver: codesandbox.io/s/concent-guide-xvcej
ts ver: codesandbox.io/s/concent-guide-ts-...

Collapse
 
creativesuraj profile image
Suraj Sharma

Sure, I will look into it.
Thanks