javascript - React.FunctionComponent 和普通的 JS 函数组件有什么区别?
问题描述
这两个例子完成了同样的事情。但是引擎盖下有什么区别?我了解功能组件与 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 函数组件。
推荐阅读
- c# - C# WPF MVVMLight 从文本框中的数据网格中获取选定项
- c# - EfCore 3.1.3 为 OrderBy 抛出 Execption
- r - R在一个时间序列中删除多个季节性
- mysql - 每个工厂的前 10 名高产量
- ios - TableViewCell 中的 TableView 与 RxSwift 绑定
- r - 使用 ggplot2 和 grid.arrange 均衡多图图中的面板高度
- c++ - std::cout 内的三元条件运算符
- python - 根据Python中的索引列表从位数组中提取位?
- javascript - Outlook 加载项中是否有取消会议功能,例如发送时
- python - 为什么 TensorFlow 2.1 不能识别我的 GPU?