React Redux表单提交未给出正确的结果

问题描述 投票:3回答:1

我正在尝试使用react和redux实现表单提交。当我在这里提交数据时,我希望得到结果(为了还原目的)。我知道我们可以通过在每个输入标签中给出'ref'来做到这一点。但我想用react-redux方法做什么呢。

demo here

您可以控制并查看作为对象获取的结果。但我没有得到正确的结果。

reactjs redux react-redux
1个回答
2
投票

我想问题是你正在使用带有redux-form的<input元素。

我推荐使用<Field name="title" component="input" type="text" />代替。

  1. 包括它import { reduxForm, Field } from 'redux-form'
  2. <Field name="title" component="input" type="text" />
  3. console.log("i want the results right here ",form.movieForm.values.title);

请注意:强烈建议在组件文件中创建一个捕获输入值的函数,然后调用dispatch动作创建器

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.