React native refer folder as name

In react native we find sometime confusing what to write path in importing .js file like “../” OR “./” etc.

Add a package.json file in a folder you want to refer as a name. Like below:

package.json is looking like this:

{“name”: “@components”}

And suppose you have one js file named Reusable1.js under that folder, so you can refer like this:

import {Reusable1} from ‘@components/Reusable1’;

Enjoy!

Git code: https://github.com/Dhrupal/referFolder