这两个例子完成了同一件事。但是引擎盖下有什么区别?我了解功能组件与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> ); };
引擎盖下没有区别。第一个是使用TypeScript语法指示类型,React.FunctionComponent但它们都是普通的JS函数组件。