4

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

3 Answers 3

23

You can rename default import like this

  import { default as CreateCustomer } from 'sales_app/src/screen/customer/Create';
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. Yeah, I got my answer in this link stackoverflow.com/questions/39282253/….
1
import CreateCustomer from 'sales_app/src/screen/customer/Create';

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.