React-native和Redux与CombineReducers-访问其他状态/属性吗?

时间:2018-07-22 23:04:00

标签: react-native redux

我从React-Native和Redux开始。我正在使用CombineReducers来简化我的reducer的工作,只传递我需要的元素(从“全局”状态)。

这是我的状态概念和我的CombineReducers代码:

状态:

{
   race: [ {...}, {...}, {...}],
   pilots: [ {...}, {...}, {...}],
   <other stuff>
}

代码:

const rootReducer = combineReducers({
    race: addLapReducer,
    pilots: editingPilotsReducer
});
const store = createStore(rootReducer, devToolsEnhancer());

这按预期工作正常。唯一的问题是,我需要从“ addLapReducer”访问“ pilots”数组。这可能吗?如果是,怎么办? 我知道如果我仅使用一个reducer(而不是CombineReducer)创建商店,则完整状态将发送到我的reducer……但是这里不是这种情况。 如果同时使用,我会努力做到的一件事:CombinedReducers和“标准” Reducer,但我不知道该怎么做。

1 个答案:

答案 0 :(得分:0)

  

唯一的问题是我需要从'addLapReducer'访问'pilots'数组

我认为访问df.groupby(df[['A', 'B']].apply(frozenset,1)).C.agg(list).apply(pd.Series) 0 1 (a, b) 1.0 3.0 (c) 1.0 NaN (a, d) 5.0 NaN 数组的更好方法是从操作创建者那里,您可以在其中返回由string projectFileName = Directory.GetCurrentDirectory() + "\\build\\Solution.sln"; ProjectCollection pc = new ProjectCollection(); Dictionary<string, string> GlobalProperty = new Dictionary<string, string>(); GlobalProperty.Add("Configuration", "Release"); GlobalProperty.Add("Platform", "Any CPU"); GlobalProperty.Add("OutputPath", Directory.GetCurrentDirectory() + "\\build\\\bin\\Release"); BuildParameters bp = new BuildParameters(pc); bp.Loggers = new[] { new FileLogger { Verbosity = LoggerVerbosity.Detailed, ShowSummary = true, SkipProjectStartedText = true } }; BuildManager.DefaultBuildManager.BeginBuild(bp); BuildRequestData BuildRequest = new BuildRequestData(projectFileName, GlobalProperty, null, new string[] { "Build" }, null); BuildSubmission BuildSubmission = BuildManager.DefaultBuildManager.PendBuildRequest(BuildRequest); BuildSubmission.Execute(); BuildManager.DefaultBuildManager.EndBuild(); if (BuildSubmission.BuildResult.OverallResult == BuildResultCode.Failure) { throw new Exception(); } } 处理的类型的操作。

例如,您有一个动作创建者,看起来像这样:

pilots

您可以更改该参数以返回带有addLapReducer参数和function somethingLaps() { return {type: ADD_LAPS, payload: 1} } 的函数,以便访问dispatch数组:

getState