0

考慮使用redux的反應本機應用程序更推薦以下目錄/文件組織中的哪一個?或者以更好的方式:哪種方法更適合react-native/redux應用程序?以下哪種方法(框架功能x應用程序上下文)最適合react-native/redux應用程序?

讓我們假定該應用程序模擬店(賣產品......)

01)的框架功能設置組織:

- package.json 
- index.android.js 
- index.ios.js 
- ... 
- src/ 
    - App.js [Main file] 
    - Router.js [Routes, Scenes,...] 
    - actions/ 
     - index.js [export all] 
     - types.js [constants, strings] 
     - SellAction.js 
     - ProductsAction.js 
     - DeliveryAction.js 
     - UsersAction.js 
     - CartAction.js 
     - ___Action.js 
    - components/ 
     - commons/ 
      - Button.js 
      - Card.js 
      - ___.js 
     - LoginForm.js 
     - ProductsList.js 
     - CartComponent.js 
     - RecentProducts.js 
     - DesirableProducts.js 
     - ___.js 
    - reducers/ 
     - index.js [combinedReducers] 
     - AuthReducer.js 
     - ProductsReducer.js 
     - DeliveryReducer.js 
     - ___Reducer.js 

02)設置組織的應用程序上下文

- package.json 
- index.android.js 
- index.ios.js 
- ... 
- src/ 
    - App.js [Main file] {combinedReducers could come to here...} 
    - Router.js [Routes, Scenes,...] {or here...} 
    - sell/ 
     - Component.js 
     - Action.js {the constants strings could be here...} 
     - Reducer.js 
     _ ... other helper files 
    - delivery/ 
     - Component.js 
     - Action.js 
     - Reducer.js 
     _ ... other helper files 
    - user/ 
     - Component.js 
     - Action.js 
     - Reducer.js 
     _ ... other helper files 
    - cart/ 
     - Component.js 
     - Action.js 
     - Reducer.js 
     _ ... other helper files 

回答

0

兩者都很好。很多人都表示傾向於「功能優先」結構。請參閱https://github.com/markerikson/react-redux-links/blob/master/project-structure.md以獲得討論各種項目結構方法的文章的鏈接。

+0

感謝markerikson。這是一個很好的參考。我喜歡JS ......但對我來說,它正在變成一個信件湯。許多名字在不同的願景中表達相同的意思。 我發現這一個https://medium.com/@yiquanzhou/how-to-structure-real-world-redux-react-application-d61e66a7dd36#.wq5dzum9j符合我對一個項目結構的概念。非常好的一個, – lordshark

相關問題