I'm having trouble solving a problem by using a single field to serve as CPF
and CNPJ
.
Then I thought of a solution, use props
to pass the type of my component, did something like this ...
state = {masked: 'cpf', cnpj: null}
<TextInputMask type={this.state.masked} onChangeText={cnpj => {this.setState({cnpj}); cnpj.length > 14 ? this.setState({masked: 'cnpj'}) : this.setState({masked: 'cpf'});}} />
Technically, this would work, but it does not work, since type cpf
does not allow more than 14 characters.