Cant export component

In reactjs typescript project …i have a Listings component :arrow_down:

//Listings.tsx

 import React from "react";

const Listings = () => {
	return <h1>Listing</h1>;
};

export default Listings;

and to handle export i have index.ts where i cant export


//index.ts
//not working..why??
export * from "./Listings";

///working
import Listings from "./Listings";

export default Listings;

Is it giving you any error output?

In Listings.tsx you’re exporting only one named export: default, even if looks like it, you don’t export Listings component as named export. In your index.ts you can do:

// Export Listings as named export
export { default as Listings } from './Listings';

// Re-export Listings as default
export default from './Listings';

1 Like

As to why export * from "./Listings"; doesn’t work, asteriks only targets named exports