Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
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
The npm package mui-form-components receives a total of 29 weekly downloads. As such, mui-form-components popularity was classified as not popular.
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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.