React container component pattern 問題

本帖最後由 清仔 於 2018-7-15 21:30 編輯

I have an app structure like this with redux:
app
|-router
| — dashboard container
| — — dashboard component
| — setting container
| — — setting component

Consider the two containers, if I need to get translation text from the store which way should I used?
(1) Connect to redux store on router and pass down to containers by props
(2) Each of the container connect to redux store individually

用context API 得唔得?我會盡量避免唔用redux

TOP

回覆 2# kc2wong
This is a question of the Container-component pattern.

TOP

好深奧

TOP

TOP

translation text用static resource唔得?
用setTimeout force reload一次就ok

TOP

本帖最後由 高原熊 於 2018-7-18 17:22 編輯

del....

TOP

回覆 6# 梁炳

yes, but not the point I want to discuss in this question

TOP

本帖最後由 梁炳 於 2018-7-19 00:16 編輯
回覆  梁炳

yes, but not the point I want to discuss in this question
清仔 發表於 2018-7-18 22:39



Redux connect to whatever components that make sense to connect to, if the component need to display User info, connect to redux

The container does not need to connect to redux if it has nothing to do with the data (e.g. purely for layout purpose)

When you are writing a component, think about how it will be used, does it make sense for the "user" component pass down the data as props to this component.  Ask yourself this, you will have an answer

don't think about performance until you face serious problem, but always keep in mind the basic principles to avoid re-rendering too often

TOP