2

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.

  • 1
    refer to this question https://stackoverflow.com/questions/39282253/how-can-i-alias-a-default-import-in-javascript – Max Oct 27 '19 at 13:24

3 Answers3

18

You can rename default import like this

  import { default as CreateCustomer } from 'sales_app/src/screen/customer/Create';
Kaushik
  • 921
  • 10
  • 18
0

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

0
import CreateCustomer from 'sales_app/src/screen/customer/Create';
Shivam Singh
  • 330
  • 2
  • 10