yumeishih / react-shopping-cart

Implement a simple shopping cart website with pure react
2 stars 0 forks source link

Better code base #1

Open chunming-c opened 6 years ago

chunming-c commented 6 years ago

Hi @yumeishih

According to basic-web-table-dealing#2 from CYBAI, it has mentioned some awesome advices. Those convention like 2 space indentation, comma style and single quote are significant. The following are my advices and I'll skip the repeated part. Hope it could be useful for you.

For dependencies, it's used for production and the following should be lain in devDependencies

root
├── package.json
├── index.html
└── src
    └── assets
    |   └── js
    |   └── style/scss
    |   └── images
    |
    └── components
    └── index.js

ref: https://jaysoo.ca/2016/02/28/organizing-redux-application/#rule-1-organize-by-feature https://github.com/facebookincubator/create-react-app#creating-an-app https://github.com/react-boilerplate/react-boilerplate

yumeishih commented 6 years ago

hi @Chun-MingChen Thanks for giving me advice! Sorry for not open another PR, because there are some problems have been solve while developing.

btw, I am not sure about where to put helper, so I put it under assets, is it okay? Here is my folder tree right now:

root
├── package.json
├── index.html
└── src
    └── assets
    |   └── helper
    |   |   └── itemFakeDatas.js
    |   └── style/scss
    |   └── images
    |
    └── components
    └── index.js
    └── store.js

Thanks again!

chunming-c commented 6 years ago

For assets folder, it aims for placing static resource like image, style or font etc. As a rule of thumb, you could re-position your helpers at the same layer as components. You may give a try. For example:

root
├── package.json
├── index.html
└── src
    └── assets
    |   └── style/scss
    |   └── images
    |
    └── components
    └── helpers
    |    └── itemFakeDatas.js
    └── index.js
    └── store.js