I am using react-phone-number-input library to take phone number inputs from users with country code. I added extra text-field as an inputComponent props of this component. My component is,
<PhoneInput
international
defaultCountry="BD"
placeholder="Enter phone number"
value={phoneNumber}
onChange={handlePhoneNumberOnChange}
countryCallingCodeEditable={false}
inputComponent={TextFieldPhoneInput}
/>
Is there any way to pass some others props to the TextFieldPhoneInput component which i used inside inputComponent? Reasons behind passing props to the TextFieldPhoneInput is, i want to validate the textfield and show some error messages as label after validation.
I solved this after adding my needed props touched, errors, directly to the component and wrapped the inputComponent with forwardRef. My Solution is,
and inside TextFieldPhoneInput component,
Now, everything works fine.