【问题标题】:Is it necessary to wrap redux form field in a form tag?是否有必要将 redux 表单字段包装在表单标签中?
【发布时间】:2019-04-02 22:15:27
【问题描述】:

我是 redux 表单的新手。我尝试利用它为我用 Typescript 编写的 react 本机应用程序中的一个文本输入字段提供的好处,实际上只是一个文本输入字段。

<Field name="payoutInput" type="text" component={this.renderPayout}/>

private renderPayout = (field: any) => (
    <View style={{flexDirection: "row", flex: 0.22, justifyContent: "flex-end"}}>
      <Text style={{fontSize: 17}}>
        $
      </Text>
      <TextInput style={{fontSize: 17}} defaultValue={String(this.props.balance)} autoFocus={true} keyboardType={'number-pad'} onEndEditing={this.calculatePayout}/>
    </View>
  )

我注意到当我在 reactotron 中监控状态时,我实际上看不到表单状态中的值。使用formValueSelector 也会给我undefined。所以我想知道是否有必要将Field 包装在一个表单中?

很高兴根据请求提供更多上下文。

【问题讨论】:

标签: react-native redux react-redux redux-form


【解决方案1】:

是的;这就是它将输入连接到 redux 表单状态的方式。

这在the redux-form docs 中注明。

redux-form 文档 note on React Native 还说要跟随 this tutorial 开始,两种资源都表明它在 React Native 下的工作方式有所不同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-15
    • 2010-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-24
    • 1970-01-01
    • 2011-04-07
    相关资源
    最近更新 更多