Days of the Deep Import Path are over for React

deep-import

 

Have you ever worked with an somewhat complex react project and had to import different components from directories from all over the project resulting in many statements like:

../.../../../components/authorized/SomeComponent.js

yea it sucks…

well if you are using a create react app bootstrap…. all you have to do now is create a jsconfig.json file at the base of your project and add this code:
{
"compilerOptions": {
"baseUrl": "src"
}
}

and the paths will looks more like so:

components/authorized/SomeComponent.js

If you need to update the relative paths for the PHPStorm IDE go to preferences, go to “Directories”, right-click the src folder and set it to be your “resource Root” and all warnings about imports should go away.

credit to alligator.io for the info, got to this article for further info.