For example, I have the following structure
+ src
|--img
| |-- logo.svg
|
|--containers
| |-- App.js
Instead of doing
import logo from "../img/logo.svg"
inside App.js it will be nice to do
import logo from "img/logo.svg"
and it will be easier to read if I have a component placed in deep directory like components/Sidebar/index.js
.
Good idea! We're having a discussion about this in #253!
What is the reason behind top-level “file type” folders? Seems like this is exactly why you want to group assets by component instead, e.g.
components
Logo
Logo.js
Logo.css
logo.svg
Well, but you might still need to import a component from a different component:
// src/containers/NavBar/Navbar.js
import NavItem from 'components/NavItem';
is a lot nicer than
// src/containers/NavBar/Navbar.js
import NavItem from '../components/NavItem';
It gets even worse if you're following a nested, route-hirarchic structure.
Most helpful comment
Well, but you might still need to import a component from a different component:
is a lot nicer than
It gets even worse if you're following a nested, route-hirarchic structure.