某些上下文:
我有一个应用程序,它使用React,Redux,React Redux。我需要在新的浏览器窗口中打开应用程序,并保持窗口同步。
我通过将redux存储作为父窗口上的全局存储来实现这一点。部分代码:
const getStore = () => {
if (window.opener)
return window.opener.__reduxStore__;
if (!window.__reduxStore__) {
window.__reduxStore__ = createStore(todoApp);
}
return window.__reduxStore__;
}
问题:
当在IE 11中打开新窗口时,一个试图改变全局状态的人得到了一个Error: Function.prototype.toString: 'this' is not a Function object
。不幸的是,我没有得到堆栈跟踪,而是File: eval code (11084), Line: 31, Column: 3
,它将我引向
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
})(Function.prototype, TO_STRING, function toString(){
return typeof this == 'function' && this[SRC] || $toString.call(this);
});
同样值得注意的是,在IE中(与Chrome或FireFox不同),redux存储对象Symbol(react.element)_<11 random characters>
上有一个属性,即undefined
我修改了展示这个问题的redux-todos示例;请参阅GitHub 上的差异
真的不知道如何跟进这件事。这是关于Symbols的Redux问题、IE问题还是React问题?
此外,IE不是在保护模式下运行。
我为这种情况创建了一个简单的中间件。这基本上是使用本地存储来保存最后一个操作,并在其他选项卡中调度相同的操作。
https://github.com/AOHUA/redux-state-sync
希望它能帮助你。