
Product
Introducing Socket MCP for Claude Desktop
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
useFormBee is a custom react hook that helps handle form input, validations and other similar functionalities
Handling forms in react can be a little bit tedious especially for new beginners like me 😃. I often find myself re-writing the same stateful logic and form validations, especially when I have different forms in different components (such as signup, login, profile update form).
My mentor @benfluleck suggested I abstract my form logic so that it can easily be reusable. I created a useForm hook and showed it to him and my other colleague. To my surprise, they loved it and adviced that I made some improvements on it and also upload it to npm as a library.
useFormBee is a custom react hook that helps me manage and abstract form logic.
Form logic such as
Harnessing the power of validatorjs, I integrated validations to the useForm hooks.
This module is distributed via npm
npm install useformbee
import useFormBee from 'useformbee';
const { values, errors, handleChange, handleSubmit, handleReset } = useFormBee({ callback, rules });
useformbee takes an object as its parameter. The object parameter must have two attribute callback
and rules
.
The callback
is the function that will be called when the form is submitted and passes all validation.
The rules
is an object of validatorjs rules
useformbee returns an object of 5 attributes.
const Form = () => {
// prepare your inputs rules
// read more about validatorjs rule -> https://www.npmjs.com/package/validatorjs
const rules = {
firstName: 'alpha|required',
age: 'numeric',
};
// create you callback function
const saveFormData = (values) => {
// ...your logic
};
const {
values, handleChange, handleSubmit, errors, handleReset,
} = useFormBee({ callback: saveFormData, rules });
// destructure field values
// the values is created from Object.keys(rules)
const { firstName, age } = values;
return (
<form onSubmit={handleSubmit} onReset={handleReset}>
<input
type='text'
value ={firstName}
onChange={handleChange}
name='firstName'
required
/>
{/* display username error if there is an error */}
{errors.firstName && <p>{errors.firstName }</p>}
<br />
<input
type='text'
value ={age}
onChange={handleChange}
name='age'
/>
{/* display age error if there is an error */}
{errors.age && <p>{errors.age}</p>}
<br />
<button type='submit'>Submit</button>
<button type='reset'>Reset</button>
</form>
);
};
Thanks goes to these people (emoji key)
Ezekiel Ilori 🤔 💻 ⚠️ 📖 | Benny Ogidan 👀 ⚠️ |
FAQs
useFormBee is a custom react hook that helps handle form input, validations and other similar functionalities
The npm package useformbee receives a total of 125 weekly downloads. As such, useformbee popularity was classified as not popular.
We found that useformbee demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.