无法从 PropTypes 获取函数
Cannot get func from PropTypes
我不明白为什么这个导入或任何其他导入不起作用:
import * as React from 'react';
import TextField from '@material-ui/core/TextField';
import * as PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
//import { PropTypes } from '@material-ui/core';
interface IProps {
value: string;
onChange?: PropTypes.func;
}
const textField = (props: IProps) => {
return (
<div>HI</div>
);
};
export default textField;
我收到的错误是:
ts-app/node_modules/@types/prop-types/index"' 没有导出成员 'func'
我在看这个文件,好像明显有这样一个成员:
export const func: Requireable<(...args: any[]) => any>;
也许有一天我会理解 React 以及这些依赖项是如何工作的,谢谢!
PropTypes.func
是一个值(旨在用于无状态功能组件的 propTypes
属性 或组件 class 的静态 属性 ),但您正试图将其用作一种类型。相反,您可以手动编写基础类型:
onChange?: (...args: any[]) => any;
或者希望更具体的适合您的应用程序。
我 filed an issue 错误消息。
我不明白为什么这个导入或任何其他导入不起作用:
import * as React from 'react';
import TextField from '@material-ui/core/TextField';
import * as PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
//import { PropTypes } from '@material-ui/core';
interface IProps {
value: string;
onChange?: PropTypes.func;
}
const textField = (props: IProps) => {
return (
<div>HI</div>
);
};
export default textField;
我收到的错误是:
ts-app/node_modules/@types/prop-types/index"' 没有导出成员 'func'
我在看这个文件,好像明显有这样一个成员:
export const func: Requireable<(...args: any[]) => any>;
也许有一天我会理解 React 以及这些依赖项是如何工作的,谢谢!
PropTypes.func
是一个值(旨在用于无状态功能组件的 propTypes
属性 或组件 class 的静态 属性 ),但您正试图将其用作一种类型。相反,您可以手动编写基础类型:
onChange?: (...args: any[]) => any;
或者希望更具体的适合您的应用程序。
我 filed an issue 错误消息。