最近在用react + redux 做開發,遇到這樣一個問題。我從后臺獲取這樣一組數據[ { type: 'button', ... }, { type: 'text', ... }]然后通過統一的方法把數據渲染成自定義的Button和Text控件。例如:let component = components[type];return React.createElement(component, {action1: action1, action2: action2});現在的問題是:我有一些action是Button控件獨有的,一些action是Text控件獨有的,我在創建控件的時候要怎么設計才可以給不同的控件傳遞不同的action而不是把所有的action都傳遞給它們?
redux中通過props傳遞action的疑問?
白豬掌柜的
2018-08-14 06:05:04