Answer the question
In order to leave comments, you need to log in
How to re-export a Typescript React component?
I have a component located in the src/MyComponent folder:
src/MyComponent/MyComponent.tsx - file with the component
src/MyComponent/index.js - the file imports and exports the component. It is needed in order to have access to the component via a short link (src/MyComponent instead of src/MyComponent/MyComponent)
When I import a component via a long link src/MyComponent/MyComponent, in the editor I see all the properties of the component in a tooltip. When I import from a short link, the properties disappear. Tell me how can I export the component so that both the component and its interface can be accessed by a short link?
The only option I found is to create an index.d.ts file:
import * as React from 'react';
Import MyComponentProps from './types.d';
declare const MyComponent: React.FC<MyComponentProps>;
export default MyComponent;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question