3 ms·
>However, for root components of a directory, use index.jsx as the filename and use the directory name as the component name I used to do this, but I find it r
by gabemart 9y ago
>However, for root components of a directory, use index.jsx as the filename and use the directory name as the component name
I used to do this, but I find it really confusing having dozens of files all called "index.jsx". I eventually moved to './ComponentName/ComponentName.jsx' in my personal projects. It's a bit more verbose, but I find it makes everything else do to with navigating and finding files easier.
- lewisl9029 9y agoAgreed that having a bunch of index.jsx files is super annoying. Though I prefer to just create a `./ComponentName.jsx` file on the same level as the `./ComponentName/` folder instead. You can still import it as `./ComponentName` as you would with having `index.jsx` inside the folder. Best of both worlds, IMO.
- ng12 9y agoVSCode makes this a little easier. It's pretty good at suggesting index.jsx if you search for "ComponentName".