首页 > 解决方案 > 无法导入 FieldInputProps react-final-form

问题描述

试图设置实际的 propTypes。但显示这样的错误

尝试导入错误:“FieldInputProps”未从“react-final-form”导出。

import { FieldInputProps, FieldMetaState } from 'react-final-form';

const TextInput = ({
  input: { name, onChange, value, type = 'text', placeholder, ...restInput },
  meta
}) => {
  .....Some Component Functionality.....
};

TextInput.propTypes = {
  input: FieldInputProps,
  meta: FieldMetaState
}

不知道为什么会发生这种情况,如何解决?

标签: reactjsreact-proptypesreact-final-formfinal-form

解决方案


在 package.json 中检查你的 react-final-form 版本。我在这个沙盒中没有错误:https://codesandbox.io/s/epic-jennings-i32w6?file=/src/App.js,使用的是 6.5.2


推荐阅读