Typescript reactjs 无法将道具传播到输入标签
Typescript reactjs Can't spread props to input tag
我有一个在整个应用程序中使用的可重用输入组件
import * as React from 'react';
import styles from "./Input.module.css";
interface Props {
input: Object;
label: string;
custom: Object;
meta: {
touched: boolean;
error: boolean;
}
}
const Input: React.SFC<Props> = ({
input,
label,
custom,
}) => (
<div className={styles.container}>
<input {...input} {...custom} />
<span className={styles.highlight} />
<span className={styles.bar} />
<label>{label}</label>
</div>
);
export default Input;
我正在将旧的 javascript 项目从 javascript 转换为打字稿。一切正常,除了当我将道具传播到输入标签中,然后打字returns这个错误。
知道导致错误的原因吗?
javascript 对象类型具有 "isPropertyOf"、"hasOwnValue" 等不适合输入元素的属性,
尝试更改为:
input: {
test: string,
id: Number
}
我有一个在整个应用程序中使用的可重用输入组件
import * as React from 'react';
import styles from "./Input.module.css";
interface Props {
input: Object;
label: string;
custom: Object;
meta: {
touched: boolean;
error: boolean;
}
}
const Input: React.SFC<Props> = ({
input,
label,
custom,
}) => (
<div className={styles.container}>
<input {...input} {...custom} />
<span className={styles.highlight} />
<span className={styles.bar} />
<label>{label}</label>
</div>
);
export default Input;
我正在将旧的 javascript 项目从 javascript 转换为打字稿。一切正常,除了当我将道具传播到输入标签中,然后打字returns这个错误。
知道导致错误的原因吗?
javascript 对象类型具有 "isPropertyOf"、"hasOwnValue" 等不适合输入元素的属性, 尝试更改为:
input: {
test: string,
id: Number
}