17
How to improve imports in your code
Hello, there!
After a while without new posts, I decided to come back with a really useful tip to simplify your code and reduce repetition.
Well, It's possible!
In order to do it, we will simply create a file named 'index.(js/ts)' inside components' folder, and add the following code in it:
And now you can import components easier from other files without needing to repeat their names.
If you think that it is still not worth it, because in index.(js/ts) the components are still being imported, there is another solution:
Instead of default exporting components
export default Input
Simply export them without default keyword
export const Input (...)
And in index.(js/ts) do this:
17