2

我在Auto complete使用开发时遇到错误final-form

必须指定一个渲染道具,一个渲染函数作为子级,或者一个组件道具到 Field(auto)

我从这个链接 https://trejgun.github.io/articles/bindings-for-using-final-form-with-material-ui-autocomplete/获得帮助

但是当我实现上面的代码时,我遇到了错误

这是我的代码 https://codesandbox.io/s/relaxed-breeze-hv58o

 <Field
              name="auto"
              multiple={true}
              component={AutoCompleteWrapper}
              placeholder="First Name"
              options={[{ label: "The Shawshank Redemption", values: 1994 }]}
            />
4

1 回答 1

0

在您的代码盒中,在 test.js 中,您将导出AutoCompleteWrapper命名导出:

export const AutoCompleteWrapper = props => {

但是在您的 index.js 文件中,您将其作为默认值导入:

import AutoCompleteWrapper from "./test";

因此,您可以通过以下两种方式之一解决此问题:

导入命名的导出

import { AutoCompleteWrapper } from "./test";

将您的导出更改为默认值

const AutoCompleteWrapper = props => {
  ...
};

export default AutoCompleteWrapper;
于 2020-01-20T18:34:00.593 回答