diff --git a/src/index.js b/src/index.js index 82a774c..dfa21a0 100644 --- a/src/index.js +++ b/src/index.js @@ -268,12 +268,14 @@ const InputMask = forwardRef(function InputMask(props, forwardedRef) { onChange: isMasked && isEditable ? onChange : props.onChange, onMouseDown: isMasked && isEditable ? onMouseDown : props.onMouseDown, ref: ref => { - inputRef.current = findDOMNode(ref); + if (ref) { + inputRef.current = findDOMNode(ref); - if (isFunction(forwardedRef)) { - forwardedRef(ref); - } else if (forwardedRef !== null && typeof forwardedRef === "object") { - forwardedRef.current = ref; + if (isFunction(forwardedRef)) { + forwardedRef(ref); + } else if (forwardedRef !== null && typeof forwardedRef === "object") { + forwardedRef.current = ref; + } } }, value: isMasked && isControlled ? lastValue : props.value