How to change default component name while importing in react native?

I want to import a component named "Create" while importing I want to change its name. But I cannot change the component name as I export the "Create" component as default.

import Create as CreateCustomer from 'sales_app/src/screen/customer/Create' ;

I am new to react-native. Need Help.

Upvotes: 4

Views: 9643

Answers (3)

Shivam Singh
Shivam Singh

Reputation: 356

import CreateCustomer from 'sales_app/src/screen/customer/Create';

Upvotes: 1

Nishad Ahamed
Nishad Ahamed

Reputation: 21

problem can be solved as below,

In the file we need to export, we can avoid "default export" and do a custom export and import in the custom name.

for example, if you need to get Button as MyButton

in the button file, we can export it as, export {Button as MyButton};

and as usual we can import it as import {MyButton} from './another-file';

Upvotes: 0

Kaushik
Kaushik

Reputation: 981

You can rename default import like this

  import { default as CreateCustomer } from 'sales_app/src/screen/customer/Create';

Upvotes: 22

Related Questions