'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.



Solution 1:[1]

You can rename default import like this

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

Solution 2:[2]

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';

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kaushik
Solution 2 Nishad Ahamed