My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Absolute Imports with Create React App - Kyle Truong - Medium

Absolute Imports with Create React App - Kyle Truong - Medium

David Homeren's photo
David Homeren
·May 25, 2017

Introduction By default ES6 modules in create-react-app use relative paths, which is fine for cases where the files you're importing are relatively close within the file tree: import { createGoal } from './actions' import { selectAuth } from './selectors'; import App from '../App'; But using relative paths is a real pain when you start dealing with deeply nested tree structures because you end up with dot-dot syndrome: import { editUser } from '../../../AppContainer/actions'; import { selectAuth } from '../../../AppContainer/selectors; And what happens when you decide you want to move that file?