我使用打字稿创建了这个:
import React, {FC} from 'react';
interface Interface {
name:string,
age:number
}
const Home: React.FC<Interface> = (info) => {
return (
<div>
<h1>{info.name}</h1>
</div>
);
};
export default Home;
///
const info = {name:'Boris', age:45}
function App() {
return (
<div className="App">
<Home info={info}/>
</div>
);
}
展开片段
...但是我从打字稿中得到一个错误: Type '{ info: { name: string; age: number; }; }' is not assignable to type 'IntrinsicAttributes & Interface & { children?: ReactNode; }'. Property 'info' does not exist on type 'IntrinsicAttributes & Interface & { children?: ReactNode; }'
问题:如何避免这种情况以及它出现的原因?
函数式编程
慕工程0101907
相关分类