I want to create components with TextInput, the default being my Input component without a mask, and the children will have a mask or some other treatment.
I currently have the default Input that contains only the styles and return the raw text as you type. I also have an Input with CPF / CNPJ mask, and at the time of export I am using an index.js file that only contains these two components and exports them.
index.js
import Input from './Input'
import CpfCnpj from './input-masks/InputCpfCnpj'
export { CpfCnpj }
export default Input
But I'd like to use it this way when you want to use it without masks:
<Input {...this.props} />
And so when you need a mask:
<Input.CpfCnpj {...this.props} />
One way I found was to do this in the index.js
import Input from './Input'
import CpfCnpj from './input-masks/InputCpfCnpj'
Input.CpfCnpj = CpfCnpj
export default Input
I wonder if there is another way, and if this is a good practice?