Skip to content

Commit 1e2e194

Browse files
committed
Update README for beforeMaskedValueChange
1 parent 66ca242 commit 1e2e194

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ Use `inputRef` instead of `ref` if you need input node to manage focus, selectio
5454
### `beforeMaskedValueChange` : `function`
5555

5656
In case you need to implement more complex masking behavior, you can provide `beforeMaskedValueChange` function to change masked value and cursor position before it will be applied to the input. `beforeMaskedValueChange` receives following arguments:
57-
1. **value** (string): New masked value.
58-
2. **cursorPosition** (number): New cursor position. `null` if change was triggered by the `blur` event.
57+
1. **newState** (object): New input state. Contains `value` and `selection` fields. `selection` is null on input blur. Example: `{ value: '12/1_/____', selection: { start: 4, end: 4 } }`
58+
2. **oldState** (object): Input state before change. Contains `value` and `selection` fields. `selection` is null on input focus.
5959
3. **userInput** (string): Raw entered or pasted string. `null` if user didn't enter anything (e.g. triggered by deletion or rerender due to props change).
6060
4. **maskOptions** (object): Mask options. Example:
6161
```js
@@ -72,11 +72,11 @@ In case you need to implement more complex masking behavior, you can provide `be
7272
}
7373
```
7474

75-
`beforeMaskedValueChange` must return an object with the following fields:
75+
`beforeMaskedValueChange` must return an object with following fields:
7676
1. **value** (string): New value.
77-
2. **cursorPosition** (number): New cursor position.
77+
2. **selection** (object): New selection. If `selection` in `newState` argument is null, it must be null too.
7878

79-
Please note that `beforeMaskedValueChange` executes more often than `onChange`, so it's recommended to make it pure.
79+
Please note that `beforeMaskedValueChange` executes more often than `onChange` and must be pure.
8080

8181

8282
## Example
@@ -134,4 +134,4 @@ class Input extends React.Component {
134134
```
135135

136136
## Thanks
137-
Thanks to [BrowserStack](https://www.browserstack.com/) for the help with testing on real devices
137+
Thanks to [BrowserStack](https://www.browserstack.com/) for the help with testing on real devices

0 commit comments

Comments
 (0)