简体   繁体   中英

Import files from parent directory into React Native app

I have a file hierarchy as follows:

-native
   -app
      -components
          login.js
-redux
    -modules
        -users.js

In my login.js file, I attempt to import the users.js redux into my code as such:

import { actions as usersActions} from "../../../redux/modules/users";

It is shared code and I cannot put the redux code in native/ The error I get is:

Unable to resolve module ../../../redux/modules/users. ... Unable to find this module in its module map or any of the node_modules directories.

I've looked at the other questions, such as: React import from parent directory but in the comments it states it to be impossible. I've also tried the fixes in https://github.com/facebook/react-native/issues/4968 but that seems to be mostly for node-modules.

尝试在引用父目录的本机目录内创建符号链接

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