是否有必要将 redux 表单字段包装在表单标签中?

Is it necessary to wrap redux form field in a form tag?

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

<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 包裹在一个表格中?

很高兴根据要求提供更多背景信息。

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

这在 the redux-form docs 中有说明。

redux-form 文档 note on React Native also says to follow this tutorial 入门,没有资源表明它在 React Native 下的工作方式不同。