是否有任何方法从存储读取而不是从组件在React-redux

Is there any way reading from store not from Component in React-redux?

本文关键字:组件 React-redux 读取 任何 方法 存储 是否      更新时间:2023-09-26

我在我的应用程序中使用React和Redux作为主要架构框架。我想创建一个简单的实用程序脚本,它向store中编写的所有ip发送请求,并为它们添加一些标头。我在Component中使用store连接的代码:

export default connect(() => {
    return {};
})(MyClass);

但是我如何连接到store在一个简单的脚本,而不是在Component ?

如果你有一个对store的引用,你可以通过

获取当前状态
store.getState()