Building Forms in React Can Be a Piece of Cake šŸ§

Written by welly | Published 2021/01/14
Tech Story Tags: react | react-hooks | web-forms | state-management | valuation | javascript | open-source | building-forms-in-react

TLDRvia the TL;DR App

Building forms inĀ ReactĀ might be a challenge. We have to face many tedious things like form data, validation, submission, and more šŸ¤Æ.
As a React developer, there're two strategies for implementing forms, theĀ controlled componentsĀ andĀ uncontrolled components, each has its advantages and timing of use. The controlled components serve form state asĀ the single source of truth. However, the uncontrolled components make our code moreĀ conciseĀ andĀ performant.
React Cool Form combines these advantages and references theĀ UX researchĀ ofĀ Nielsen Norman GroupĀ as the basis for ourĀ APIĀ design to help you conquer all kinds of forms šŸ‘ŠšŸ».

Let's Getting Started

We're going to build a basic signup form with validation as below:
To use React Cool Form, you must useĀ [email protected]Ā or greater which includes hooks. This package is distributed viaĀ npm.
$ yarn add react-cool-form
# or
$ npm install --save react-cool-form
Here's the implementation, you can play it via CodeSandbox:
With React Cool Form, we can also integrate a 3rd-party UI library with our form seamlessly. We take Material-UI as an example:
āœØĀ Pretty easy right? Check the full API documentation to learn more about it.

Written by welly | Code x Design āœØ
Published by HackerNoon on 2021/01/14