以下是我的react组件结构(使用TypeScript):

-App.tsx

  -NewRequestForm.tsx

    -EmployeeInfo.tsx

    -AssetInfo.tsx

我正在尝试在NewRequestForm中导入EmployeeInfo&AssetInfo,但是在使用import语句时,两个组件都不可见,但是我可以看到Prop&States接口(interface)。

reactjs - React-TypeScript : How to import component?-LMLPHP

请建议如何在NewFormRequest.tsx中导入子组件

AssetInfo.tsx(child1)
import * as React from 'react';

export interface AssetInfoProps {}
export interface AssetInfoState {}

export default class AssetInfo extends React.Component<AssetInfoProps,
AssetInfoState> {
  constructor(props: AssetInfoProps) {
    super(props);

    this.state = {};
  }

  public render() {
    return <div />;
  }
}

EmployeeInfo.tsx(Child2)
import * as React from 'react';

export interface EmployeeInfoProps {}
export interface EmployeeInfoState {}

export default class EmployeeInfo extends React.Component<EmployeeInfoProps,
EmployeeInfoState> {
  constructor(props: EmployeeInfoProps) {
    super(props);

    this.state = {};
  }

  public render() {
    return <div />;
  }
}

NewRequestForm.tsx(父)
import * as React from 'react';
import {} from './EmployeeInfo';
import {} from './AssetInfo';

export interface NewRequestFormProps {}

export default class NewRequestForm extends
React.Component<NewRequestFormProps, any> {
  public render() {
    return <div />;
  }
}

最佳答案

删除用于导出defaultEmployeeInfo关键字

关于reactjs - React-TypeScript : How to import component?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51556020/

10-11 11:27