简体   繁体   English

未捕获(承诺)类型错误:无法读取未定义的属性“过滤器”

[英]Uncaught (in promise) TypeError: Cannot read property 'filter' of undefined

I created a react-app which I deployed online with npm run build , now everything locally works fine but when I try to load a page on my app it gives a error in Container.js ( no idea what this file is and what it does )我创建了一个使用npm run build在线部署的 react-app,现在本地一切正常,但是当我尝试在我的应用程序上加载页面时,它在Container.js出现错误(不知道这个文件是什么以及它做什么)

i've tried to reinstall all the node_modules without any result so I cloned my repo fresh but still without any result我尝试重新安装所有 node_modules 没有任何结果,所以我克隆了我的 repo 新鲜但仍然没有任何结果

Container.js:容器.js:

'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _reactRedux = require('react-redux');

var _Container = require('../components/Container');

var _Container2 = _interopRequireDefault(_Container);

function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : {
    default: obj
  };
}
/**
 * src/containers/Container.jsx
 */


var mapStateToProps = function mapStateToProps(store, ownProps) {
  return {
    items: store[ownProps.reduxStoreName].content[ownProps.reduxUid].filter(function (item) {
      return item.parentId === ownProps.itemId;
    })
  };
};

exports.default = (0, _reactRedux.connect)(mapStateToProps)(_Container2.default);

Error in console: Uncaught (in promise) TypeError: Cannot read property 'filter' of undefined控制台错误:未捕获(承诺)类型错误:无法读取未定义的属性“过滤器”

well, like @Pointy mentioned in his comment, it basically means that store[ownProps.reduxStoreName].content[ownProps.reduxUid] is undefined.好吧,就像在他的评论中提到的@Pointy 一样,它基本上意味着store[ownProps.reduxStoreName].content[ownProps.reduxUid]是未定义的。 It is not the file which is causing the error, its the specific line.导致错误的不是文件,而是特定的行。 When the code reaches this line and tries to execute it- that store[ownProps.reduxStoreName].content[ownProps.reduxUid] parameter is undefined so it crushes.当代码到达这一行并尝试执行它时 - store[ownProps.reduxStoreName].content[ownProps.reduxUid]参数未定义,因此它崩溃了。

We cannot tell you where the error is, we'd need the code of your whole app to follow the execution flow.我们无法告诉您错误在哪里,我们需要您的整个应用程序的代码来遵循执行流程。 You have to follow it yourself, and understand why there is not an array in that variable when the code gets there.您必须自己遵循它,并理解为什么当代码到达那里时该变量中没有数组。

As a general idea, try figure out the following:作为一般想法,请尝试弄清楚以下内容:

  1. when and where that variable is initialized?该变量何时何地初始化?

  2. when and where do you call mapStateToProps?何时何地调用 mapStateToProps?

  3. are you absolutely sure that the code which answers question 1 is executed before the code which answers to question 2?您绝对确定回答问题 1 的代码在回答问题 2 的代码之前执行吗? (maybe there is an asynchronous execution problem you didn't think about which causes your code to execute at the wrong order) (也许有一个你没有想到的异步执行问题导致你的代码以错误的顺序执行)

  4. if it does- maybe the way you initialize those variables at the beggining is not correct?如果确实如此 - 也许您在开始时初始化这些变量的方式不正确? maybe you use a 3rd party library / function to initialize them, but not actually getting the result you expecting?也许您使用 3rd 方库/函数来初始化它们,但实际上并没有得到您期望的结果? or maybe you're using it wrong, or parsing the result wrong?或者您使用错误,或者解析结果错误?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的类型错误:无法读取未定义的属性“过滤器” - Uncaught TypeError: Cannot read property 'filter' of undefined 未捕获的TypeError:无法读取未定义的属性“过滤器” - Uncaught TypeError: Cannot read property 'filter' of undefined 未捕获(承诺中):TypeError:无法读取未定义的属性“userSubject”类型错误:无法读取未定义的属性“userSubject” - Uncaught (in promise): TypeError: Cannot read property 'userSubject' of undefined TypeError: Cannot read property 'userSubject' of undefined 未捕获(承诺)TypeError:无法读取未定义的属性'uid' - Uncaught (in promise) TypeError: Cannot read property 'uid' of undefined 未捕获(承诺)类型错误:无法读取未定义的属性“fisierUrl” - Uncaught (in promise) TypeError: Cannot read property 'fisierUrl' of undefined 未捕获(承诺):TypeError:无法读取未定义的属性“ router” - Uncaught (in promise): TypeError: Cannot read property 'router' of undefined 错误:未捕获(承诺):TypeError:无法读取未定义的属性“ customerName” - Error: Uncaught (in promise): TypeError: Cannot read property 'customerName' of undefined 未捕获(承诺)TypeError:无法读取未定义的属性“ ui5” - Uncaught (in promise) TypeError: Cannot read property 'ui5' of undefined 需要帮助->未捕获(承诺)TypeError:无法读取未定义的属性“ length” - Need help -> Uncaught (in promise) TypeError: Cannot read property 'length' of undefined 未捕获(承诺)TypeError:无法读取未定义的属性“ content” - Uncaught (in promise) TypeError: Cannot read property 'content' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM