This is called Barel export and it helps with tree shaking and bundle resolution. In large project it helps to bundle it faster. I do recommend to use barel exports.
I also like the convenience of importing components from components instead of components/button that's why I sometimes find myself using these index files
In my tabs I see header, footer, leftbar etc... I have used it and I found myself great with it, but as always it is a matter of preference, there is no you must do this or that, you are free to choose any style you like
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It’s a lot of index.js. Do you ever find that’s inconvenient in the code editor tabs? My team did and no longer use index.js files.
This is called Barel export and it helps with tree shaking and bundle resolution. In large project it helps to bundle it faster. I do recommend to use barel exports.
Regards!
I also like the convenience of importing components from
components
instead ofcomponents/button
that's why I sometimes find myself using these index filesFor my projects instead of index.js I call them the name of the folder example header/header.js it is more clean and you'll not get confused
how is it clean ? header/header its like repeatition. is it gonna be
wow
If you use default export it would be, you don't need to explicitly say import Header, in my prospective it is not needed
Yes you are repeating the name, you are right, but you solve the problem of having multiple index.js.
As example you have main.js file that is importing all the components:
Now if in my editor I have all this files open I see 4 index.js files, if I call the in this other way:
In my tabs I see header, footer, leftbar etc... I have used it and I found myself great with it, but as always it is a matter of preference, there is no you must do this or that, you are free to choose any style you like