Bob Aleena
Bob Aleena

Reputation: 460

"autoCapitalize" is not a valid style property - error in ReactNative

I am receiving an error when trying to autoCapitalize. If I remove it, the component renders, but auto capitalize is on by default in ios (not android though). I want to add the property to ensure consistency.

This is the error (I removed the full listing of properties in order to condense)

"autoCapitalize" is not a valid style property  StyleSheet loginActionText: {
     "color": "#000",
      "fontSize": 20,
      "autoCapitalize": "none"
    }
    Valid style props: [
      "alignContent",
      "alignItems", 
      . 
      . 
      .
      "width",
      "writingDirection",
      "zIndex"
    ]

My code is really straight forward. I have defined a style class

 loginActionText: {
    color: '#000',
    fontSize: 20,
    autocapitalize: 'none'
  },

and then I am applying it to a Text Input

<TextInput style={styles.loginActionText}
  label='Email Address'
  placeholder='[email protected]'
  value={this.state.email}
  onChangeText={email => this.setState({ email })}
/>

Upvotes: 4

Views: 12244

Answers (1)

K.Wu
K.Wu

Reputation: 3633

autoCapitalize should be used this way:

<TextInput
    ...
    autoCapitalize='none'
    ...
/>

instead of being a property of the style object

Upvotes: 13

Related Questions