top | item 16132379

(no title)

gabemart | 8 years 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.

discuss

order

lewisl9029|8 years ago

Agreed 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|8 years ago

VSCode makes this a little easier. It's pretty good at suggesting index.jsx if you search for "ComponentName".