File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -34,18 +34,22 @@ export default class TextInputMask extends Component {
3434 }
3535 }
3636
37- componentWillReceiveProps ( nextProps ) {
38- if ( nextProps . mask && ( this . props . value !== nextProps . value ) ) {
39- mask ( this . props . mask , '' + nextProps . value , text =>
40- this . input && this . input . setNativeProps ( { text } )
41- ) ;
37+ componentDidUpdate ( prevProps , _ , snapshot ) {
38+ if ( snapshot . mask && prevProps . value !== snapshot . value ) {
39+ mask ( prevProps . mask , "" + snapshot . value , text => this . input && this . input . setNativeProps ( { text } ) ) ;
4240 }
4341
44- if ( this . props . mask !== nextProps . mask ) {
45- setMask ( findNodeHandle ( this . input ) , nextProps . mask )
42+ if ( prevProps . mask !== snapshot . mask ) {
43+ setMask ( findNodeHandle ( this . input ) , snapshot . mask ) ;
4644 }
4745 }
4846
47+ getSnapshotBeforeUpdate ( ) {
48+ const { mask : maskValue , value } = this . props ;
49+
50+ return { mask : maskValue , value } ;
51+ }
52+
4953 render ( ) {
5054 return ( < TextInput
5155 { ...this . props }
Original file line number Diff line number Diff line change 11{
22 "name" : " react-native-text-input-mask" ,
3- "version" : " 1.0.6 " ,
3+ "version" : " 1.0.7 " ,
44 "description" : " Text input mask for React Native." ,
55 "main" : " index.js" ,
66 "repository" : {
You can’t perform that action at this time.
0 commit comments