Heroku,NodeJs和React问题:SCRIPT5007:无法获取未定义或空引用的属性"apply" [英] Heroku, NodeJs and React issue: SCRIPT5007: Unable to get property 'apply' of undefined or null reference
问题描述
我猜我对polyfill有一个奇怪的问题.我为应用程序使用了MERN堆栈,然后推送到Heroku.出于某种原因,我可以在Chrome的计算机上查看该网站,但是,在其他计算机上却出现空白页和控制台错误:
I have a weird issue with, I guess, polyfills. I used MERN stack for my app, and pushed to Heroku. For some reason, on my computer in Chrome I can view the website, however, on other computers I'm getting a blank page and the error in console:
'SCRIPT5007: Unable to get property 'apply' of undefined or null reference'
它指向这段代码,并且显然链接到Redux:
it points to this chunk of code, and, apparently, is linked to Redux:
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(undefined, arguments));
};
});
}
我将babel-polyfill导入了我的App.js文件,甚至将<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,es6"></script></script>
添加到了index.html
,但还是没有运气.如何解决这个问题?
I imported babel-polyfill to my App.js file, even added <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,es6"></script></script>
to index.html
but still no luck. What could be done to solve this?
UPD:看来原因是Redux Dev Tools.我需要以某种方式在生产中禁用它.
推荐答案
显然,该问题与我使用的Redux DevTools有关.因此,在redux store.js中,我必须更改此设置:
Apparently, the issue was linked with the Redux DevTools that I was using. So, in redux store.js I had to change this:
const store = createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
window._REDUX_DEVTOOLS_EXTENSION_ ? window.__REDUX_DEVTOOLS_EXTENSION__() // Error is this line
)
);
对此:
const store = createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() : f => f
)
);
一切正常.
这篇关于Heroku,NodeJs和React问题:SCRIPT5007:无法获取未定义或空引用的属性"apply"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!