import PhoneInput, { formatPhoneNumber, formatPhoneNumberIntl, isValidPhoneNumber } from 'react-phone-number-input';
const [fields, setFields] = React.useState([{ value: null }]);
<PhoneInput
id="phoneNumbers1"
type="text"
placeholder="Enter phone number "
value={field.value || ""}
defaultCountry="US"
international
name="phoneNumbers"
error={disable}
autoComplete='off'
onBlur={formik.handleBlur}
onChange={(e) => handleChange(idx, e)}
onClick={() => setIndex(idx)}
/>
<button
type="button"
hidden={fields.length > 1}
data-value={fields.length}
disabled={!fields[0]?.value && !(isValidPhoneNumber(fields[0]?.value ||''||fields.length<10))}
onClick={() => handleAdd()}
>
+ Phone
</button>
Inside button inside disable property if I try to give condition that button is disabled until user give 10 digit phone number with condition field.length < 10. It throws an error "TypeError: A text for parsing must be a string." What should be the condition inside disable attribute that until user give 10 digit phone number button should disable?