Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why placeholder text is not showing of textInput field in react-native?

Tags:

react-native

I want to make a text input field where placeholder text will show "Enter your digit" in react-native, Now problem is, the placeholder text is not showing until i am pressing any key in the keyboard. If i elaborate then when i am running the app placeholder text is empty, if i click on text input field then keyboard appears. Now if i press any digit then it shows those digit perfectly and if i press cross button and delete all digit which i entered only that time that placeholder text shows. I am new in react-native so if someone know about the problem then please explain before answer because so far i have not got any detail about this matter. So far what i have done.

<TextInput style={styles.textField} placeholder="Enter your digit" placeholderTextColor= 'red' keyboardType= 'numeric'> </TextInput>

like image 947
Emon Avatar asked Dec 18 '22 19:12

Emon


1 Answers

I think it's because the textinput has some value in his value property, can you try to use value='' ?

 <TextInput 
  style={styles.textField} 
  placeholder="Enter your digit" 
  placeholderTextColor= 'red' 
  value=''
  keyboardType= 'numeric' />

If that works try using some state value like this.state.text, and make the initial value null or '' (empty string)

like image 76
ValdaXD Avatar answered Jun 01 '23 02:06

ValdaXD