Skip to content

Commit

Permalink
fix: handle ref callback on unmount when ref is null
Browse files Browse the repository at this point in the history
See sanniassin#254 - I just
didn't like the coding style
  • Loading branch information
Ian Channing committed Feb 22, 2023
1 parent 0096454 commit e4761e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 12 additions & 12 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"dist/react-input-mask.js": {
"bundled": 72695,
"minified": 23386,
"gzipped": 7853
"bundled": 72770,
"minified": 23398,
"gzipped": 7859
},
"lib/react-input-mask.development.js": {
"bundled": 29107,
"minified": 12289,
"gzipped": 4078
"bundled": 29174,
"minified": 12301,
"gzipped": 4083
},
"dist/react-input-mask.min.js": {
"bundled": 30538,
"minified": 10487,
"gzipped": 3761
"bundled": 30613,
"minified": 10499,
"gzipped": 3768
},
"lib/react-input-mask.production.min.js": {
"bundled": 27970,
"minified": 11212,
"gzipped": 3750
"bundled": 28037,
"minified": 11224,
"gzipped": 3755
}
}
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ const InputMask = forwardRef(function InputMask(props, forwardedRef) {
});

const refCallback = node => {
// handle unmount
if (node === null) {
return;
}
inputRef.current = node;

// if a ref callback is passed to InputMask
Expand Down

0 comments on commit e4761e3

Please sign in to comment.