Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Export image file as module React TypeScript

Let’s say I have a folder with an image file and an index file (it acts like a public API), is there a way to reexport the image with another name?.

The folder structure is as following:

└── assets/
      ├── index.ts
      └── facebook.png

Is there a way to reexport the image file with a name?, like the following:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

index.ts:

export * as FacebookLogo from "./facebook.png"

>Solution :

In the index.js file of your api folder…

import FacebookLogo from './facebook.png';

export {
  FacebookLogo,
  /** other exports */
};
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading