TpoM6oH
TpoM6oH

Reputation: 8575

How to import and export the same thing

I want to achieve something like this:

import {colors} from '../../basestyle'
export const colours = colors

but with the same name for imported and exported constants.

Upvotes: 0

Views: 49

Answers (2)

Vishal
Vishal

Reputation: 6368

You won't believe it. Its a one liner:

export * from '../../basestyle';

or you will be able to do this:

export {colors} from '../../basestyle';

Update to OP's comment:

To use it in same file and also export after importing it you can do it like this:

export { colors } from '../../basestyle';

const MyComponent = props => {
    console.log(colors);
    return <div>;
}

export default MyComponent;

Upvotes: 1

Rohith Murali
Rohith Murali

Reputation: 5669

To export only colors, you can do the following,

export { colors } from '../../basestyle';

To export all the exported content from '../../basestyle'; you can,

export * from '../../basestyle';

Upvotes: 2

Related Questions