
Product
A New Design for GitHub PR Comments
We redesigned our GitHub PR comments to deliver clear, actionable security insights without adding noise to your workflow.
react-use-form-data
Advanced tools
This custom React Hook lets you easily populate and update form input data state within functional components.
This custom React Hook lets you easily populate and update form input data within functional components.
Example of use with an editor
It can be useful for prototyping with form editors that need to control sub-component props. The demo used in React Video Looper uses this hook to manage the form data state, passing props down to the video component.
Currently it's configured to handle the following input field types: number, text, button and checkbox.
npm i react-use-form-data
<script type="text/javascript" src="https://unpkg.com/react-use-form-data/umd/react-use-form-data.js"></script>
//1. IMPORT THE HOOK
import React from 'react'
import useFormData from 'react-use-form-data'
export default function Demo() {
// 2. CALL THE HOOK WITH INITIAL DATA AS NAME-VALUE PAIRS
const [formData, updateFormData] = useFormData({
numberField: 101,
textField: 'hello world',
checkboxField: true
});
// 3. FORM FIELDS THEN READ IN STATE DATA FROM formData AND UPDATE DATA VIA updateFormData
return (
<div>
<input type='number'
value={formData.numberField}
onChange={(evt) => updateFormData('numberField', evt)}
data-testid='numberField' />
<input type='text'
value={formData.textField}
onChange={(evt) => updateFormData('textField', evt)}
data-testid='textField' />
<input type='checkbox'
checked={formData.checkboxField}
onChange={(evt) => updateFormData('checkboxField', evt)}
data-testid='checkboxField'/>
</div>
)
}
See sample file in demo/umd-example.html
MIT © Lewis Hunt
FAQs
This custom React Hook lets you easily populate and update form input data state within functional components.
The npm package react-use-form-data receives a total of 7 weekly downloads. As such, react-use-form-data popularity was classified as not popular.
We found that react-use-form-data 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
We redesigned our GitHub PR comments to deliver clear, actionable security insights without adding noise to your workflow.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Security News
Slopsquatting is a new supply chain threat where AI-assisted code generators recommend hallucinated packages that attackers register and weaponize.