Javascript react和flow:在一行中导入节点类型和PureComponent
如何在一行中导入Javascript react和flow:在一行中导入节点类型和PureComponent,javascript,reactjs,react-native,ecmascript-6,flowtype,Javascript,Reactjs,React Native,Ecmascript 6,Flowtype,如何在一行中导入节点(flow使用的类型)和PureComponent,仅用于代码纯度 下面的行不起作用: import type { Node }, { PureComponent } from 'react'; // or import type { Node, PureComponent } from 'react'; 注意:我实际上使用这个 /* @flow */ import { PureComponent } from 'react'; import type { Node } f
节点
(flow使用的类型)和PureComponent
,仅用于代码纯度
下面的行不起作用:
import type { Node }, { PureComponent } from 'react';
// or
import type { Node, PureComponent } from 'react';
注意:我实际上使用这个
/* @flow */
import { PureComponent } from 'react';
import type { Node } from 'react';
提前感谢前面提到的文档中所写的,对于使用命名类型导入,您需要在默认导入之外添加 同样,如果您
import React with:import React from'React'
您将能够访问React.Component、React.createElement()、React.Children、
和其他JavaScript值。但是,您将无法访问React.Node、React.ChildrenArray
或其他流类型。
除了您的默认导入之外,您还需要使用命名类型导入,如:从'React'导入类型{Node}。
尝试此操作
import { type Node, PureComponent } from 'react';
工作正常且干净。您确定节点
是反应
包的一部分吗?@ArnoldGandarillas我添加了实际工作的行。如果找到节点
导入