File and folder naming convention for React.js components
/actions/...
/components/common/Link.js
/components/common/...
/components/forms/TextBox.js
/components/forms/TextBox.res/style.css
/components/forms/TextBox.locale/en-US/...
/components/forms/...
/components/layout/App.js - The top-level React component
/components/layout/App.res/style.css
/components/layout/App.locale/en-US/...
/components/layout/Navigation.js
/components/layout/Navigation.res/style.css
/components/layout/Navigation.res/data.json
/components/layout/Navigation.locale/en-US/...
/components/layout/...
/components/pages/Home.js
/components/pages/Home.css
/components/pages/Account/index.js
/components/pages/Account/index.css
/components/pages/...
/core/...
/constants/...
/stores/...
/actions/...
/components.common/Link.js
/components.common/...
/components.forms/TextBox.js
/components.forms/TextBox.css
/components.forms/...
/components.layout/App.js
/components.layout/Navigation.js
/components.layout/...
/components.pages/Home.js
/components.pages/Home.css
/components.pages/Account/index.js
/components.pages/Account/index.css
/components.pages/...
/core/...
/constants/...
/stores/...
CSS class names should be prefixed with a single letter corresponding to the component's type.
For example:
Component: /components/forms/TextBox.js
, CSS class name: f-textbox { ... }
Component: /components/layout/Navigation.js
, CSS class name: l-nagiation { ... }
I'm not sure I agree with using uppercase letters in file names. This could cause problems later when working with case sensitive file systems (like linux). As an example, you could create a file name
/components/forms/TextBox.js
and a different file named/components/forms/textbox.js
on Linux but this will wreak havoc on an insensitive filesystem like OSX the moment you try to check out that code.try this:
on a mac open a file name
tmp
and write some stuff in it.. then read the fileTMP
. It will be the same file... do the same on Linux and you will seetmp != TMP
This is why most frameworks that provide file generators (rails as an example) always generate lowercased filenames.
As a proof of concept... try cloning this example repository: https://github.com/parabuzzle/SensitiveCaseIsSensitive
notice on a mac how you're missing a file...
The scenario is this...
Developer A is working on a Mac and Developer B is working on Linux...
Developer A checks in a file named
Links.js
while Developer B creates a file namedlinks.js
Developer B pulls the latest changes from Developer A and no merge conflicts happen.
Developer B commits changes and pushes up.
The code works in production (production is Linux).. but when Developer A pulls down the code, it doesn't work locally because
Links.js
is gone in favor of the newerlinks.js
.Confusion ensues as to how the code even works at all in production...