Open jamesl1001 opened 4 years ago
<PhoneInput
ref={ref => {
phoneno = ref;
}}
onChangePhoneNumber ={(num)=>{
setPhone(num)
}}
style={{marginLeft:"20%"}}
initialCountry = 'us'
textProps={{
placeholder:I18n.t('phone'),
returnKeyType: 'done',
keyboardType: 'phone-pad',
style:(styles.input)
}}
/>
This works
That's because you are not using the textComponent
prop.
Hey, based on this line , some probs such as the change listener are passed to the component, so instead of using your own onChangeText
, you could try to pass the probs to the underlying element like:
textComponent={(props) => (
<>
<Text>Mobile number</Text>
<View>
<Text onPress={() => this.test.onPressFlag()}>+{this.state.countryCode}</Text>
<TextInput
keyboardType="phone-pad"
// onChangeText={text => this.test.setState({ inputValue: text })}
placeholder="7123456789"
{...props}
/>
</View>
</>
)}
I am having the same problem
same issue. any one find an answer?
Any updates on the issue? I even cannot get the value from the phone input using onChangePhoneNumber once I am using custom textComponent
I had the same issue but then I figured out that I was using textComponent like that:
textComponent={() => ( <MyInput /> )
while I actually had to pass props:
textComponent={(props) => ( <MyInput {...props} /> )
I want to use the various methods such as
isValidNumber()
,getNumberType()
,getValue()
, getISOCode()` etc.When I use the
textComponent
prop to customise the UI, how do I pass the value from this custom TextInput into the PhoneInput's state to be used by those methods?