将Redux状态传递给调度程序

时间:2019-03-26 10:06:00

标签: reactjs redux recompose

我目前正在编写一个React项目(使用redux和recompose),并试图将我的redux状态传递到连接内的调度中。

我想避免编写两次连接代码,但必须这样做才能使Object处于状态,以便调度程序可以从我的本地状态获取它。

这是它的外观:

equals

我想立即使用Option Explicit Sub Subst() With ThisWorkbook.Sheets("Sheet1") Dim ArrayColumnD As Variant ArrayColumnD = .Range("D1:D" & .Cells(.Rows.Count, 4).End(xlUp).Row) Dim ArrayColumnG As Variant ArrayColumnG = .Range("G1:G" & .Cells(.Rows.Count, 7).End(xlUp).Row) Dim ID As String Dim RowActual As Long Dim RowTest As Long For RowActual = 2 To UBound(ArrayColumnD) If ArrayColumnG(RowActual, 1) = "Good" Then ID = ArrayColumnD(RowActual, 1) For RowTest = 2 To UBound(ArrayColumnD) If ArrayColumnD(RowTest, 1) = ID Then ArrayColumnG(RowTest, 1) = "Good" End If Next RowTest End If Next RowActual .Range("G1:G" & .Cells(.Rows.Count, 7).End(xlUp).Row) = ArrayColumnG End With End Sub 并实现以下功能:

currentLocaleCode

这可能吗?

1 个答案:

答案 0 :(得分:0)

您可以简单地将数据作为道具传递给组件,而不用使用两个connect HOC,并使用所需数据调用操作创建者

喜欢

export default compose(
  connect(({locales: { currentLocaleCode }}) => ({ currentLocaleCode }),
  (dispatch) => ({
    fetchArticles: (dispatch) => ({
      fetchPage: =>
        (currentLocaleCode) => dispatch(pagesActions.fetchPage(currentLocaleCode))
    })
  })),
...

,在连接的组件中,您将调用fetchPage之类的

this.props.fetchPage(this.props.currentLocaleCode);