最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - I can't make autoCapitalize to work properly - Stack Overflow

programmeradmin2浏览0评论

I have a custom ponent like below

<Input
  value={value}
  style={styles.input}
  secureTextEntry={passwordInput && !this.state.showPassword}
  onChangeText={onChangeText}
  autoCapitalize={disableAutoCapitalize ? 'none' : 'words'}
  autoCorrect={!disableAutoCorrect}
  editable={!notEditable}
/>

But when I try to set autoCapitalize to words it's not working, why?

<InputField
  disableAutoCapitalize={false}
  disableAutoCorrect
/>

I have a custom ponent like below

<Input
  value={value}
  style={styles.input}
  secureTextEntry={passwordInput && !this.state.showPassword}
  onChangeText={onChangeText}
  autoCapitalize={disableAutoCapitalize ? 'none' : 'words'}
  autoCorrect={!disableAutoCorrect}
  editable={!notEditable}
/>

But when I try to set autoCapitalize to words it's not working, why?

<InputField
  disableAutoCapitalize={false}
  disableAutoCorrect
/>
Share Improve this question edited Oct 12, 2018 at 10:32 Roy Scheffers 3,90811 gold badges33 silver badges36 bronze badges asked Oct 5, 2018 at 9:07 AnXDAnXD 2552 gold badges4 silver badges15 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 1

disableAutoCapitalize is passed in as a prop I assume. You should use this.props.disableAutoCapitalize.

<Input
  value={value}
  style={styles.input}
  secureTextEntry={passwordInput && !this.state.showPassword}
  onChangeText={onChangeText}
  autoCapitalize={this.props.disableAutoCapitalize ? 'none' : 'words'}
  autoCorrect={!disableAutoCorrect}
  editable={!notEditable}
/>

It is working on iOS but not on Android(Galaxy S9), it looks like a react native bug.

Its a react native bug that is fixed after 0.61.5. But in short, remove keyboardType, if possible, then autoCapitaliz will work for you

See these issues for a backstory: https://github./facebook/react-native/issues/27510 https://github./facebook/react-native/issues/8932

发布评论

评论列表(0)

  1. 暂无评论