Skip to content

Commit 097f0b8

Browse files
committed
Added the "Event Callbacks" section to the readme
1 parent c6b475a commit 097f0b8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function myFormat(num) {
5858
```
5959

6060
## Props
61-
Option | Type | Default
61+
Name | Type | Default
6262
-------------|-------------------------------------|:-------:
6363
**value** |`number` or `string` | `""` which converts to 0
6464
**min** |`number` | `Number.MIN_SAFE_INTEGER`
@@ -78,6 +78,14 @@ Any other option is passed directly the input created by the component. Just
7878
don't forget to camelCase the attributes. For example `readonly` must be `readOnly`.
7979
See examples/index.html for examples.
8080

81+
## Event Callbacks
82+
You can pass callback props like `onClick`, `onMouseOver` etc. and they will be
83+
attached to the input element and React will call them with `null` scope and the corresponding event. However, there are few special cases to be aware of:
84+
85+
* `onChange` - Called with `valueAsNumber` and `valueAsString`. The `valueAsNumber` represents the internal numeric value while `valueAsString` is the same as the input value and might be completely different from the numeric one if custom formatting is used.
86+
* `onInvalid` - Will be called with `errorMessage`, `valueAsNumber` and `valueAsString`.
87+
* `onValid` - There is no corresponding event in browsers. It will be called when the component transitions from invalid to valid state with the same arguments as onChange: `valueAsNumber` and `valueAsString`.
88+
8189
## Styling
8290
The component uses inline styles which you can customize. The `style` prop is not added
8391
directly to the component but instead it is a container for styles which you can overwrite.

0 commit comments

Comments
 (0)