Closed jdnichollsc closed 6 years ago
I choose based on context. In React components I usually use relative paths as components can be moved around and between projects etc. I like to use absolute paths for helpers etc as the absolute path always works if i need to refactor or move files around :)
There isn't really a right answer here. Whatever makes more sense for your project! Some things which are more top-level might be moved around less frequently, whereas components in a complicated tree might be moved around regularly.
It all depends on your project requirement, Projects folder structure is complex and deep use absolute imports, folder structure is comparatively simple use relative imports. Wish to improve code readability use relative imports otherwise use absolute imports. JS community usually use relative imports in libraries but as I said it all depends on your requirement.
Still if you want a solid answer, Airbnb style guide say that if your dependencies are less than two level deep use relative imports, whereas, if your dependencies are more than two level deep use absolute imports. Please find a link to such discussion: https://docs.gitlab.com/ee/development/new_fe_guide/style/javascript.html
Hi guys,
One question, what is better?
or
Thanks for this excellent example! I've created a blank template too (Based on this template, I need to update the documentation)
Regards, Nicholls