这两个示例完成了相同的事情。但是,在底层有什么区别呢?我了解函数组件与React.Component和React.PureComponent之间的区别,但我还没有找到有关 React.FunctionComponent
的相关文档。
React.FunctionComponent
const MyComponentA: React.FunctionComponent = (props) => {
return (
<p>I am a React.FunctionComponent</p>
);
};
纯JS函数组件:
const MyComponentB = (props) => {
return (
<p>I am a plain JS function component</p>
);
};