
Security News
pnpm 10.16 Adds New Setting for Delayed Dependency Updates
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
react-deferred-input
Advanced tools
React input component that defers onChange handler until input is blurred
npm install react-deferred-input
See demo HERE.
Form inputs in React can either be controller or uncontrolled (see here). Controlled components always display the value
prop they are passed and need to trigger the onChange
handler every time a character is added or removed so that they can be updated. Uncontrolled components render the initial defaultValue
prop they get passed and after that they render what the user types into them.
This component gives you the functionality of a controlled component that always displays the value
prop that it is given EXCEPT when a user is focused on the input then it waits till the user blurs and then only triggers the onChange
(and onBlur
) handlers if the value has change.
This can dramatically reduce the number of network requests that get sent.
import React, { Component } from 'react';
import DeferredInput from 'react-deferred-input';
class MyComponent extends Component {
render() {
return (
<DeferredInput value='initial value' onChange={this.handleChange} />
);
}
handleChange(value) {
console.log("this is only called when the input is blurred with the value: ", value);
}
}
Prop Name | Description | Default Value |
---|---|---|
value | input value | String: '' |
onChange | handler called with one argument (input value) on blur (required) | Function: undefined |
onBlur | handler called with one argument (input value) on blur | Function: undefined |
blurOnEnter | should input blur when press ENTER key | Boolean: false |
focusOnMount | should input be focused when initially mounted | Boolean: false |
clearOnChange | should input value be cleared on blur | Boolean: false |
inputComponent | component to be used for actual input | 'input' |
Any other custom props will be passed on to input component.
MIT
FAQs
React input component that defers onChange handler until input is blurred
We found that react-deferred-input 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's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.