2

I'm having an issue when I try to custom my TextInput whereas the placeholder will have normal fontWeight and the textinput will be bold.

This is my code for that:

<TextInput
    placeholder={'Input'}
    style={{ width: '100%', fontWeight: this.state.text.length > 0 ? 'bold' : 'normal' }}
    value={this.state.text}
    onChangeText={(text) => {
           this.setState({
                 text,
             });
       }}
/>

My issue is: Firstly, placeholder have normal fontWeight, i entered some randomly input and then delete all of it, the placeholder style is not change back to normal but still be bold.

enter image description here

Brian H.
  • 1,603
  • 11
  • 16
  • Try this: style={{ width: '100%', fontWeight: this.state.text.length === 0 ? 'normal' : 'bold' }} or you can also try style={{ width: '100%', fontWeight: this.state.text === "" ? 'normal' : 'bold' }} – Rohan Rao Aug 21 '20 at 03:47
  • @noobprogrammer tks for that. But that not work man :( I just update my screenshot for easier understand my issue. – Brian H. Aug 21 '20 at 03:59

0 Answers0