React-Native import files outside of main directory
My problem is I cannot import files outside of the demo app
Here is the structure I have
|– Components/
| |– libs
| |– node_modules
| |– index.js
| |– package.json
| |– demo/
| | |– node_modules
| | |– App.js
| | |– package.json
Inside of demo/App.js, I am trying to import one of my components from the upper directory but with no luck. All the components are exported in ./index.js
Inside of App.js, I tried : import {MyComponent} from ‘Components’, import {MyComponent} from ‘../index’, or import {MyComponent} from ‘../../Components/’ but none seem to work.
I got the following type of error Directory /Users/Manda/web/my projects/Components/index doesn’t exist
What Am I doing wrong?
Monic Thereon
You can create a rn-cli.config.js file in demo folder and add the following code:
var path = require("path");
var config = {
watchFolders: [
path.resolve(__dirname,"../"),
]
}
module.exports = config;