Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-numeric-input
Advanced tools
Number input component that can replace the native number input which is not yet very well supported and where it is, it does not have the same appearance across the browsers. Additionally this component offers more flexible options and can be used for an
Number input component that can replace the native number input which is not yet very well supported and where it is, it does not have the same appearance across the browsers. Additionally this component offers more flexible options and can be used for any values (differently formatted representations of the internal numeric value).
npm install react-number-nput --save
Then in your scrips:
// es6
import NumericInput from 'react-numeric-input';
// or es5
var NumericInput = require('react-numeric-input');
This will behave exactly like <input type="number">
. It will create an empty
numeric input that starts changing from zero. The difference that this works on
any browser and does have the same appearance on each browser.
<NumericInput/>
// or:
<NumericInput className="form-control"/>
Most of the time you will need to specify min
, max
and value
:
<NumericInput min={0} max={100} value={50}/>
You can use step
and precision
props to make your input working with
floating point numbers:
<NumericInput step={0.1} precision={2} value={50.3}/>
By default the component displays the value number as is. However, you can
provide your own format
function that will be called with the numeric value
and is expected to return the string that will be rendered in the input:
function myFormat(num) {
return num + '$';
}
<NumericInput precision={2} value={50.3} step={0.1} format={myFormat}/>
Option | Type | Default |
---|---|---|
value | number | 0 |
min | number | Number.MIN_SAFE_INTEGER |
max | number | Number.MAX_SAFE_INTEGER |
step | number | 1 |
precision | number | 0 |
parse | function | parseFloat |
format | function | none |
Any other option is passed directly the input created by the component. Just
don't forget to camelCase the attributes. For example readonly
must be readOnly
.
See examples/index.html for examples.
This component comes with styles written in LESS and precompiled to CSS in src/style. It's up to you to decide how to use them but here are a few options:
require('node_modules/react-numeric-input/src/style/NumericInput.less');
.
See examples/examples.jsx for example.step / 10
).
Note that this will only work if you have specified a precision
option that supports it.step * 10
).MIT
FAQs
Number input component that can replace the native number input which is not yet very well supported and where it is, it does not have the same appearance across the browsers. Additionally this component offers more flexible options and can be used for an
The npm package react-numeric-input receives a total of 29,622 weekly downloads. As such, react-numeric-input popularity was classified as popular.
We found that react-numeric-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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.