Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-TypeScript: How to import component?

Below is my react components structure (Using TypeScript):

-App.tsx

  -NewRequestForm.tsx

    -EmployeeInfo.tsx

    -AssetInfo.tsx

I am trying to import EmployeeInfo & AssetInfo in NewRequestForm, but while using import statement both components are not visible, but I can see Prop & States interfaces.

enter image description here

Please suggest how child components can be imported in my 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 (Parent)

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 />;
  }
}
like image 480
Sandeep Nandey Avatar asked Jul 27 '18 10:07

Sandeep Nandey


1 Answers

Remove the default keyword for exporting the EmployeeInfo

like image 52
Murat Karagöz Avatar answered Sep 23 '22 20:09

Murat Karagöz