我很困惑为什么以下不起作用
GroupList.js
export default Relay.createContainer(List, {
...
})
转化为:
exports.List = List;
exports['default'] = _reactRelay2['default'].createContainer(List, {
}
});
将其导入如下操作
import GroupList from './GroupList';
或
import {default as GroupList} from './GroupList';
但以下工作
export const GroupList = Relay.createContainer(List, {
..
});
转化为:
exports.List = List;
var GroupList = _reactRelay2['default'].createContainer(List, {
...
});
exports.GroupList = GroupList;
并像在这个WORKS中那样导入它。
import {GroupList} from './GroupList';
那么,有什么区别?也就是说,如果我使用表格
,如何将其导入另一个文件export default Relay.createContainer(List, {
已编译导入:
var _GroupList = __webpack_require__(324);
webpack模块:
/***/ },
/* 324 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module) {'use strict';
...
var GroupList = (0, _redux.compose)((0, _utilsRelay2['default'])({
...
}))(List);
exports.GroupList = GroupList;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(34)(module)))
/***/ },
/* 325 */
已编译导入:
var _GroupList = __webpack_require__(324);
webpack模块:
/***/ },
/* 324 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module) {'use strict';
...
exports.List = List;
exports['default'] = (0, _redux.compose)(
...
}))(List);
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(34)(module)))
/***/ },
/* 325 */
错误:
Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components)
or a class/function (for composite components) but got: undefined. Check the render method of `GroupContainer`.
invariant @ invariant.js:39
instantiateReactComponent @ instantiateReactComponent.js:64
instantiateChild @ ReactChildReconciler.js:29traverseAllChildrenImpl @ traverseAllChildren.js:98
traverseAllChildren @ traverseAllChildren.js:186
ReactChildReconciler.instantiateChildren @ ReactChildReconciler.js:52
ReactMultiChild.Mixin._reconcilerInstantiateChildren @ ReactMultiChild.js:197