Monday, July 4, 2022
HomeTechnologyWhy and How to Use Absolute Imports in React | by Sabesan...

Why and How to Use Absolute Imports in React | by Sabesan Sathananthan


import {MyComponent} from ‘components/MyComponent’;

Using TypeScript

Using JavaScript

import {MyComponent} from ‘components/MyComponent’;
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@component/*": ["src/components/*"],
}
}
}
import {MyComponent} from ‘@component/MyComponent’;

For VS Code

For WebStrom / IntelliJ Idea

With ESLint

By Convention

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments