
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
mui-form-components
Advanced tools
Utility wrappers and hooks for managing forms with react and material ui
Opinionated utility wrappers and hooks for managing forms with react and material ui.
The purpose of this library is to make the process of building high performance forms as easy as possible. With a few opinionated assumptions about how form UX should work, this library exports a useForm hook along with a handful of Material-UI form components that have been wrapped with utilities like validation and state management.
Install
npm install mui-form-components
Simple Usage:
import {TextField, useForm} from 'mui-form-components';
import Button from '@mui/material/Button';
const MyForm = () => {
const {valid, data, form, reset} = useForm();
const handleSubmit = useCallback(() => {
console.log('Do something with this form data: ', data)
reset();
}, [])
return (
<div>
<TextField
form={form}
name="firstName"
label="First name"
/>
<Button
onClick={handleSubmit}
disabled={!valid}
>
Submit
</Button>
</div>
)
}
Lets look at some of the things a developer would typically have to ask themselves when building a form with React and Material-UI.
useState value or is there a single object with key/value pairs?Lets look at how mui-form-components approaches each of these problems. Taking the example from above:
useForm hook, based on the name prop. Data would end up looking like {firstName: 'bob'}.useForm hook or your parent component. In the text field, the input is validated on every change event, so the input itself runs fast and knows exactly when it becomes invalid / valid. The value of the input (plus meta data on its validity) is debounced and communicated back up to the useForm hook (and your component) once every 150 milliseconds. This is fast enough for the user to barely perceive a delay, but a 15x reduction in the amount of times useHook and your component need to re-render. Again, the input renders in real time, but your compoent renders only when the input sends an updated value. This means you can have a submit button change its disabled state based on whether the entire form is valid or not.useForm hook provides a reset function that can be called to do just that.FAQs
Utility wrappers and hooks for managing forms with react and material ui
We found that mui-form-components 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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.