![](/img/trans.png)
[英]React app working locally but application error when deployed to heroku
[英]React app working on localhost but giving error when deployed either on github or on heroku. No error while deploying
我创建了一个反应应用程序来显示不同国家的电晕感染。 这在我的本地主机上工作,但是当我在 github 或 heroku 上部署它时,会生成一个错误。 以下错误在块引用中给出。 当我检查文件country.js时查看错误,没有n[0] 。 请帮助下面是托管应用程序和应用程序的github存储库的链接。
TypeError: "n[0] is undefined" E country.js:13 E country.js:11 React 7 stable_runWithPriority scheduler.production.min.js:19 React 6 a App.js:22 u runtime.js:45 _invoke runtime .js:274 t runtime.js:97 r asyncToGenerator.js:3 a asyncToGenerator.js:25 react-dom.production.min.js:209:194 React 5unstable_runWithPriority scheduler.production.min.js:19 React 4unstable_runWithPriority scheduler.production.min.js:19 React 6 a App.js:22 u runtime.js:45 _invoke runtime.js:274 t runtime.js:97 r asyncToGenerator.js:3 a asyncToGenerator.js:25 TypeError: n [0] 是未定义的 country.js:13:30
这是在Heroku链接托管应用和这是链接到托管在Github上的应用
正如Dishant Desai 所说,它给出了一个类型错误。 为了修复它,您可以将country.js
的代码从
const countryflag = Object.keys(data).map((name) => {
return data[name][0];
})
到
const countryflag = data[0];
并以这种方式直接使用它:
${countryflag[country[0]]}
我检查了你的网站,它给出了以下错误:
react_devtools_backend.js:6 TypeError: Cannot read property 'Afghanistan' of undefined
at country.js:13
at Array.map (<anonymous>)
at E (country.js:11)
at Ki (react-dom.production.min.js:153)
at Fo (react-dom.production.min.js:175)
at va (react-dom.production.min.js:263)
at cu (react-dom.production.min.js:246)
at au (react-dom.production.min.js:246)
at Za (react-dom.production.min.js:239)
at react-dom.production.min.js:123
因此,为此,您必须共享该文件的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.