简体   繁体   中英

How to resolve module name conflict in react native

I have two module with the exact same name that belongs to two different apps, these two module are functionally quite similar except for the styling. I am creating a master component and try to import these two different module based on what app I am currently in.

I wonder if there is a way to conditionally import the module that I don't have to hard code a name space for the module, like module_app1 and module_app2 but instead to do

if (cond) {
    import module from 'path1';
} else {
    import module from 'path2';
}

I use 'as'. Example:

import Actions from '../actions';
import { Actions as Navigator } from 'react-native-router-flux';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM