Skip to content

Commit 899175d

Browse files
committed
Make it work as a native TextInput component when mask props is not set
1 parent ae917d5 commit 899175d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

index.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default class TextInputMask extends Component {
3434
}
3535

3636
componentWillReceiveProps(nextProps) {
37-
if (this.props.value != nextProps.value) {
37+
if (nextProps.mask && (this.props.value !== nextProps.value)) {
3838
mask(this.props.mask, '' + nextProps.value, text =>
3939
this.input && this.input.setNativeProps({ text })
4040
);
@@ -56,9 +56,13 @@ export default class TextInputMask extends Component {
5656
}
5757
}}
5858
onChangeText={masked => {
59-
const _unmasked = unmask(this.props.mask, masked, unmasked => {
60-
this.props.onChangeText && this.props.onChangeText(masked, unmasked)
61-
})
59+
if (this.props.mask) {
60+
const _unmasked = unmask(this.props.mask, masked, unmasked => {
61+
this.props.onChangeText && this.props.onChangeText(masked, unmasked)
62+
})
63+
} else {
64+
this.props.onChangeText && this.props.onChangeText(masked)
65+
}
6266
}}
6367
/>);
6468
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-text-input-mask",
3-
"version": "0.6.1",
3+
"version": "0.6.2",
44
"description": "Text input mask for React Native on iOS and Android.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)