【问题标题】:debugging react-native TextInput behaviour调试 react-native TextInput 行为
【发布时间】:2016-04-12 20:00:20
【问题描述】:

我正在向我的 react-native 应用程序添加简单的日期屏蔽。它有效,似乎在https://rnplay.org/apps/3twbCw 的 rnplay 中,它不适用于我的应用程序。

屏蔽函数为:

dateFormat(text) {
  if (text.match(/^\d{2}$/) !== null) {
    text += '/';
  } else if (text.match(/^\d{2}\/\d{2}$/) !== null) {
    text += '/';
  }
  this.setState({birthdate: text});
}

我将这个函数应用/调用为:

<TextInput
  key='birthdateTxt'
  style={styles.formField}
  returnKeyType='done'
  ref={(ref) => this.birthdateInput = ref}
  onFocus={() => this.inputFocused(this.birthdateInput)}
  value={this.state.birthdate}
  onChangeText={(text) => this.dateFormat(text)}
  onSubmitEditing={() => this.register()}
/>

函数被调用。从调试输出中可以清楚地看到这一点。然而 this.setState({birthdate: text}) 不会改变 TextInput 的值。 rnplay 样本似乎在做同样的事情,但它没有表现出同样的问题。

我要检查什么?

【问题讨论】:

  • 这个问题发生在 0.17 的 App 构建和 rnplay 在 0.13rc 上运行。到目前为止,这是我注意到的唯一可能的原因。

标签: javascript ios react-native


【解决方案1】:

TextInput 在 0.17 中显然部分损坏。

【讨论】:

    猜你喜欢
    • 2019-01-15
    • 2016-04-11
    • 2017-12-28
    • 2018-12-01
    • 1970-01-01
    • 2018-09-11
    • 1970-01-01
    • 2023-03-23
    • 2018-08-01
    相关资源
    最近更新 更多