【发布时间】:2021-09-19 20:44:20
【问题描述】:
运行这个命令:
npx react-native init AwesomeProject
在App.js 文件中我不明白 2 行:
import React from 'react';
import type {Node} from 'react'; // 1
import {
SafeAreaView,
ScrollView,
// ..... Code ....
const App: () => Node = () => { // 2
// ..... Code ....
export default App;
-
导入类型节点
按照Is there a point to doing 'import type' rather than 'import' with Flow?,我了解到这种导入是用来导入一个类型的对象,例如:
import type { Array, Object, ... } from 'wherever';说实话,我更关心下一点(如果我明白我也会自动得到这个)。
-
const App: () => Node = () =>我所看到的只是 App 是一个 变量,它引用了一个函数,该函数返回一个
Node类型的对象,这Object也是一个函数。它是否将应用程序包装到“反应”实例或其他东西中?
【问题讨论】:
-
() => Node是 类型。
标签: javascript node.js reactjs react-native import