Open rlaphoenix opened 3 days ago
I made an edit to the _inherits
function:
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function");
+ throw new TypeError(`Super expression must either be null or a function: ${superClass}, subClass:\n${subClass}`);
And an edit to the Grid.js file where I copied the function that encapsulated the call to _inherit and named it poop
with otherwise no changes. I copied it outside of and before the function, and then replaced Grid
in the _inherit call with poop
.
This leads me to believe that WebPack is cutting off the /*..*/}(React.PureComponent)
bit at the end of the function, therefore it is undefined.
Bug Report
I'm unable to reproduce in Sandbox, probably because it's not using WebPack.
What is the current behavior?
When Grid calls _inherit() from babel, the subClass is the Grid function, but the superClass (which should be
_React$PureComponent
) is actuallyundefined
. This results in an error as the _inherit function makes sure that it is a function being passed.The subClass being passed to _inherit (after webpack via NextJS) is:
The subClass being passed (after webpack via NextJS) is:
```js function Grid(props) { var _this; _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()( this, Grid ); _this = _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()( this, _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default()( Grid ).call(this, props) ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_onGridRenderedMemoizer", (0, _utils_createCallbackMemoizer__WEBPACK_IMPORTED_MODULE_12__["default"])() ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_onScrollMemoizer", (0, _utils_createCallbackMemoizer__WEBPACK_IMPORTED_MODULE_12__["default"])( false ) ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_deferredInvalidateColumnIndex", null ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_deferredInvalidateRowIndex", null ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_recomputeScrollLeftFlag", false ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_recomputeScrollTopFlag", false ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_horizontalScrollBarSize", 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_verticalScrollBarSize", 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_scrollbarPresenceChanged", false ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_scrollingContainer", void 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_childrenToDisplay", void 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_columnStartIndex", void 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_columnStopIndex", void 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_rowStartIndex", void 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_rowStopIndex", void 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_renderedColumnStartIndex", 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_renderedColumnStopIndex", 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_renderedRowStartIndex", 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_renderedRowStopIndex", 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_initialScrollTop", void 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_initialScrollLeft", void 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_disablePointerEventsTimeoutId", void 0 ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_styleCache", {} ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_cellCache", {} ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_debounceScrollEndedCallback", function () { _this._disablePointerEventsTimeoutId = null; // isScrolling is used to determine if we reset styleCache _this.setState({ isScrolling: false, needToResetStyleCache: false, }); } ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_invokeOnGridRenderedHelper", function () { var onSectionRendered = _this.props.onSectionRendered; _this._onGridRenderedMemoizer({ callback: onSectionRendered, indices: { columnOverscanStartIndex: _this._columnStartIndex, columnOverscanStopIndex: _this._columnStopIndex, columnStartIndex: _this._renderedColumnStartIndex, columnStopIndex: _this._renderedColumnStopIndex, rowOverscanStartIndex: _this._rowStartIndex, rowOverscanStopIndex: _this._rowStopIndex, rowStartIndex: _this._renderedRowStartIndex, rowStopIndex: _this._renderedRowStopIndex, }, }); } ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_setScrollingContainerRef", function (ref) { _this._scrollingContainer = ref; } ); _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_7___default()( _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_5___default()( _this ), "_onScroll", function (event) { // In certain edge-cases React dispatches an onScroll event with an invalid target.scrollLeft / target.scrollTop. // This invalid event can be detected by comparing event.target to this component's scrollable DOM element. // See issue #404 for more information. if (event.target === _this._scrollingContainer) { _this.handleScrollEvent(event.target); } } ); var columnSizeAndPositionManager = new _utils_ScalingCellSizeAndPositionManager__WEBPACK_IMPORTED_MODULE_11__[ "default" ]({ cellCount: props.columnCount, cellSizeGetter: function cellSizeGetter(params) { return Grid._wrapSizeGetter(props.columnWidth)(params); }, estimatedCellSize: Grid._getEstimatedColumnSize(props), }); var rowSizeAndPositionManager = new _utils_ScalingCellSizeAndPositionManager__WEBPACK_IMPORTED_MODULE_11__[ "default" ]({ cellCount: props.rowCount, cellSizeGetter: function cellSizeGetter(params) { return Grid._wrapSizeGetter(props.rowHeight)(params); }, estimatedCellSize: Grid._getEstimatedRowSize(props), }); _this.state = { instanceProps: { columnSizeAndPositionManager: columnSizeAndPositionManager, rowSizeAndPositionManager: rowSizeAndPositionManager, prevColumnWidth: props.columnWidth, prevRowHeight: props.rowHeight, prevColumnCount: props.columnCount, prevRowCount: props.rowCount, prevIsScrolling: props.isScrolling === true, prevScrollToColumn: props.scrollToColumn, prevScrollToRow: props.scrollToRow, scrollbarSize: 0, scrollbarSizeMeasured: false, }, isScrolling: false, scrollDirectionHorizontal: _defaultOverscanIndicesGetter__WEBPACK_IMPORTED_MODULE_13__.SCROLL_DIRECTION_FORWARD, scrollDirectionVertical: _defaultOverscanIndicesGetter__WEBPACK_IMPORTED_MODULE_13__.SCROLL_DIRECTION_FORWARD, scrollLeft: 0, scrollTop: 0, scrollPositionChangeReason: null, needToResetStyleCache: false, }; if (props.scrollToRow > 0) { _this._initialScrollTop = _this._getCalculatedScrollTop(props, _this.state); } if (props.scrollToColumn > 0) { _this._initialScrollLeft = _this._getCalculatedScrollLeft( props, _this.state ); } return _this; } ```What is the expected behavior?
It should have passed the expected
React.PureComponent
function, I presume, yet it didn't. It seems like WebPack cut it out. The Source code has it passed to this _inherit call as an argument in it's wrapped:I presume React.PureComponent was removed here, or lost in some sort.
Which versions of React and react-virtualized, and which browser / OS are affected by this issue? Did this work in previous versions of react-virtualized?