Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redux saga 初步結構 #1

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

horsekitlin
Copy link

No description provided.

@kyoyadmoon
Copy link
Member

想要討論一下元件的資料夾結構
目前components目錄裡面每個資料夾是一個screen
container則只負責做connect redux,這部分我覺得其實可以合起來,不曉得多一層隔開是不是有什麼其他考量?
另外可能也需要一個專門放元件的資料夾(可能有些跨頁面的元件)

因此我的想法是可以將元件依下列的資料夾進行劃分歸類

  • components:和 redux 沒有連結的元件
  • containers: 和 redux 連結的元件
  • screens: 每個畫面


每一個資料夾代表一個頁面

描述顯示在瀏覽器上的 HTML CSS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這裡好像打錯了?

@horsekitlin
Copy link
Author

containers 主要是要表示的是每一個頁面跟 reducers 和 action 的關係
例如哪些 reducer 改變會影響到這個頁面
以及這個頁面有什麼 actions 可以使用
程式碼部分其實一致性蠻高的
有想過可以寫一個 json 來做設定檔案
或是用 decorator 處理
感覺上應該也不錯
但是因為當時還要處理 babel 的 plugin
我就沒有加上去了

而 components 主要是每個頁面的渲染結構
在處理 HTML 和 CSS 的相關顯示
所以我把這兩個部分拆開來

在共用的部分我習慣會在 components/ 開一個 utils 的資料夾
他會放置所有的共用元件
或是可能寫到一半發現某些元件重用性高
也是拆出來這邊

@horsekitlin
Copy link
Author

而且以我的認知來說
containers 不會有 HTML CSS 這類的程式碼在裡面
所以才會完全分開的

@kyoyadmoon
Copy link
Member

如果不是native 和 web 共存的 case,我想應該需要有分離 native 和 web 的 package.json 機制

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants