如何将零钱存入商店 redux-form

How to put change in store redux-form

我正在使用 react-autosuggest 进行自动完成输入(获取类型)。我的代码基于 AutoCompleteArrayInput 来自 react-admin 和 react-autosuggest in material-ui。我用 addField 装饰我的组件,以便使用 redux-form with.

但是,当我将我的组件放入 SimpleForm 时,提取和选择工作正常,所有输入在 redux 存储中都有一个值,但不是我的。当我查看 React 开发工具时,我的组件周围有一个 Field 组件

我尝试通过 change 从 redux-form 手动完成,但它不起作用。 如何在 redux 存储中连接我的组件以提交我的所有输入?

export default connect(
  null,
  {
    getSearched: crudGetAll,
  },
)(
  compose(
    addField,
    translate,
  )(ButtonSearchWithAutocompletion),
);
onSuggestionSelected = (event, { suggestion }) => {
    const { onSelectedValue, source } = this.props;

    change(REDUX_FORM_NAME, source, suggestion.id);
    onSelectedValue(suggestion);
  };

我团队中有人帮助我解决了这个问题,对于遇到同样问题的任何人,解决方案是,将 redux-formchange 放在我的 index.js 中,就像这样:

import { change } from 'redux-form';
import { connect } from 'react-redux';
import compose from 'recompose/compose';

import ButtonSearchWithAutocompletion from './component';

export default connect(
  null,
  {
    getSearched: crudGetAll,
    change,
  },
)(
  compose(
    addField,
    translate,
  )(ButtonSearchWithAutocompletion),
);

在我的 component.js 中,我使用 change 作为道具 :

onSuggestionSelected = (event, { suggestion }) => {
    const { onSelectedValue, source, change } = this.props;

    change(REDUX_FORM_NAME, source, suggestion.id);
    onSelectedValue(suggestion);
  };

希望对您有所帮助!