作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 react-magnific-popup 包,但是当我从该包中导入任何内容时,出现此错误“类型错误:无法读取未定义的属性‘对象’”
./node_modules/react-magnific-popup/lib/SingleImage.js
node_modules/react-magnific-popup/lib/SingleImage.js:59
56 | exports.SingleImage = SingleImage;
57 |
58 | SingleImage.propTypes = {
> 59 | config: _react2['default'].PropTypes.object.isRequired,
60 | className: _react2['default'].PropTypes.string.isRequired,
61 | href: _react2['default'].PropTypes.string.isRequired,
62 | children: _react2['default'].PropTypes.element.isRequired,
View compiled
__webpack_require__
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:678
675 | };
676 |
677 | // Execute the module function
> 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
679 |
680 | // Flag the module as loaded
681 | module.l = true;
View compiled
fn
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:88
85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
86 | hotCurrentParents = [];
87 | }
> 88 | return __webpack_require__(request);
89 | };
90 | var ObjectFactory = function ObjectFactory(name) {
91 | return {
View compiled
./node_modules/react-magnific-popup/lib/ReactMagnificPopup.js
node_modules/react-magnific-popup/lib/ReactMagnificPopup.js:7
4 | value: true
5 | });
6 |
> 7 | var _SingleImage = require('./SingleImage');
8 |
9 | Object.defineProperty(exports, 'SingleImage', {
10 | enumerable: true,
View compiled
__webpack_require__
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:678
675 | };
676 |
677 | // Execute the module function
> 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
679 |
680 | // Flag the module as loaded
681 | module.l = true;
View compiled
fn
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:88
85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
86 | hotCurrentParents = [];
87 | }
> 88 | return __webpack_require__(request);
89 | };
90 | var ObjectFactory = function ObjectFactory(name) {
91 | return {
View compiled
./src/pages/artistsPage/artists.js
http://localhost:3000/static/js/bundle.js:65258:79
__webpack_require__
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:678
675 | };
676 |
677 | // Execute the module function
> 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
679 |
680 | // Flag the module as loaded
681 | module.l = true;
View compiled
fn
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:88
85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
86 | hotCurrentParents = [];
87 | }
> 88 | return __webpack_require__(request);
89 | };
90 | var ObjectFactory = function ObjectFactory(name) {
91 | return {
View compiled
./src/App.js
http://localhost:3000/static/js/bundle.js:59016:85
__webpack_require__
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:678
675 | };
676 |
677 | // Execute the module function
> 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
679 |
680 | // Flag the module as loaded
681 | module.l = true;
View compiled
fn
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:88
85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
86 | hotCurrentParents = [];
87 | }
> 88 | return __webpack_require__(request);
89 | };
90 | var ObjectFactory = function ObjectFactory(name) {
91 | return {
View compiled
./src/index.js
http://localhost:3000/static/js/bundle.js:62672:63
__webpack_require__
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:678
675 | };
676 |
677 | // Execute the module function
> 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
679 |
680 | // Flag the module as loaded
681 | module.l = true;
View compiled
fn
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:88
85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
86 | hotCurrentParents = [];
87 | }
> 88 | return __webpack_require__(request);
89 | };
90 | var ObjectFactory = function ObjectFactory(name) {
91 | return {
View compiled
0
http://localhost:3000/static/js/bundle.js:68288:18
__webpack_require__
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:678
675 | };
676 |
677 | // Execute the module function
> 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
679 |
680 | // Flag the module as loaded
681 | module.l = true;
View compiled
./node_modules/ansi-regex/index.js.module.exports
/Users/user/Desktop/reactProjs/juz/webpack/bootstrap 9134a036f8ac4d969428:724
721 | __webpack_require__.h = function() { return hotCurrentHash; };
722 |
723 | // Load entry module and return exports
> 724 | return hotCreateRequire(0)(__webpack_require__.s = 0);
725 |
726 |
727 |
View compiled
(anonymous function)
http://localhost:3000/static/js/bundle.js:728:10
最佳答案
我也面临同样的问题。我将按照以下步骤解决此问题。
1) 安装 prop-types;
2) 声明 PropTypes 'var PropTypes = require('prop-types');'
进入以下文件。 i) SingleImage.js, LightBoxGallery.js, Popup.js.
也更换
_react2['default'].PropTypes. into PropTypes.
关于reactjs - 导入 "TypeError: Cannot read property ' 包时出现错误 "React-Magnific-Popup"object' of undefined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50291743/
我是一名优秀的程序员,十分优秀!