使用 redux-thunk 组合 reducer state

Using redux-thunk to combine reducer state

我目前正在 React 应用程序上编写一个 redux-thunk 操作,它在任何方面都不是异步的,但它允许我绕过通过具有不同的 reducer 函数(使用 combineReducers)生成的状态的封装。

基本上,我需要一个动作来合并来自两个不同减速器的数据,我意识到我可以使用 getState 参数使用 thunk(我已经将其用于异步动作)来完成此操作。

这让我可以处理我猜测的边缘情况,而不必重新考虑我的状态的封装。

我的问题是:我应该警惕这种方法吗?这在任何方面都是不好的做法吗?

谢谢!

很好,那就是one of the approaches we suggest in the Redux FAQ entry on working with state slices