Skip to content

Commit

Permalink
Fix maxLength warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sanniassin committed May 17, 2018
1 parent 8124869 commit 62798cd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ class InputElement extends React.Component {
if (this.maskOptions.mask && this.getInputValue() !== this.value) {
this.setInputValue(this.value);
}

warning(
!!(this.props.maxLength && this.maskOptions.mask),
'react-input-mask: You shouldn\'t pass maxLength property to the masked input. It breaks masking and unnecessary because length is limited by the mask length.'
);
}

componentDidUpdate() {
Expand Down Expand Up @@ -512,6 +507,13 @@ class InputElement extends React.Component {
render() {
var { mask, alwaysShowMask, maskChar, formatChars, inputRef, beforeMaskedValueChange, children, ...props } = this.props;

warning(
// parse mask to test against actual mask prop as this.maskOptions
// will be updated later in componentDidUpdate
!props.maxLength || !parseMask(mask, maskChar, formatChars).mask,
'react-input-mask: maxLength property shouldn\'t be passed to the masked input. It breaks masking and unnecessary because length is limited by the mask length.'
);

var inputElement;
if (children) {
invariant(
Expand Down

0 comments on commit 62798cd

Please sign in to comment.