Last active
July 3, 2019 02:40
-
-
Save FrenchMajesty/6758013397e065a831211879423818fd to your computer and use it in GitHub Desktop.
Ant Design Input and React-Text-Mask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
import MaskedInput from 'react-text-mask'; | |
import { Icon, Input } from 'antd'; | |
class PhoneNumberInput extends Component { | |
render() { | |
return ( | |
<MaskedInput | |
mask={['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]} | |
guide={false} | |
showMask | |
render={(ref, props) => <Input ref={(input) => ref(input && input.input)} prefix={<Icon type="phone" />} {...props} />} | |
{...this.props} | |
/> | |
); | |
} | |
} | |
PhoneNumberInput.propTypes = { | |
onChange: PropTypes.func, | |
'data-__field': PropTypes.object, | |
value: PropTypes.string, | |
}; | |
export default PhoneNumberInput; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment