{"record":{"id":"f909594acf67a74c","repo":"bvaughn/react-virtualized","slug":"windowscroller-registerchild-expects-to-be-passed","errorCode":null,"errorMessage":"WindowScroller registerChild expects to be passed Element or null","messagePattern":"WindowScroller registerChild expects to be passed Element or null","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"source/WindowScroller/WindowScroller.js","lineNumber":198,"sourceCode":"      'div',\n      {\n        ref: this._windowScrollerRef,\n      },\n      children({\n        onChildScroll: this._onChildScroll,\n        registerChild: this._registerChild,\n        height,\n        isScrolling,\n        scrollLeft,\n        scrollTop,\n        width,\n      }),\n    );\n  }\n\n  _registerChild = element => {\n    if (element && !(element instanceof Element)) {\n      console.warn(\n        'WindowScroller registerChild expects to be passed Element or null',\n      );\n    }\n    this._child = element;\n    this.updatePosition();\n  };\n\n  _onChildScroll = ({scrollTop}) => {\n    if (this.state.scrollTop === scrollTop) {\n      return;\n    }\n\n    const scrollElement = this.props.scrollElement;\n    if (scrollElement) {\n      if (typeof scrollElement.scrollTo === 'function') {\n        scrollElement.scrollTo(0, scrollTop + this._positionFromTop);\n      } else {\n        scrollElement.scrollTop = scrollTop + this._positionFromTop;","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/bvaughn/react-virtualized/blob/c737715486f724586aee8870ebea1e9efb7b0bfe/source/WindowScroller/WindowScroller.js#L180-L216","documentation":"WindowScroller's `_registerChild` warns when the registered child ref is not a DOM Element or null. WindowScroller needs the child element to compute offsets and attach scroll/resize handlers relative to the window. Like CellMeasurer's version, this indicates the child ref points at something other than a DOM node.","triggerScenarios":"Passing a class component or non-forwarding component as WindowScroller's child; `registerChild` called manually with a non-Element; ref callback returning a value (React 19 cleanup semantics).","commonSituations":"Wrapping Grid/List in a custom component inside WindowScroller without forwardRef; higher-order components that don't pass refs through; React version upgrades changing ref behavior.","solutions":["Render a DOM element (or a forwardRef component resolving to one) as WindowScroller's direct child.","Wrap custom components in React.forwardRef attaching the ref to the outer DOM node.","Ensure Grid/List inside WindowScroller receives `autoHeight` so it sizes correctly in the window-scroll context.","Only call `registerChild` with an Element or null."],"exampleFix":"// before\n<WindowScroller>{({height}) => <MyList height={height} />}</WindowScroller>\n\n// after (MyList forwards ref to its DOM/container element, Grid via forwardRef)\n<WindowScroller>\n  {({height, registerChild}) => (\n    <MyList ref={registerChild} autoHeight height={height} />\n  )}\n</WindowScroller>","handlingStrategy":"type-guard","validationCode":"const ok = (el) => el === null || (typeof Element !== 'undefined' && el instanceof Element);\nif (process.env.NODE_ENV !== 'production' && !ok(childRef.current)) console.warn('WindowScroller child ref is not an Element');","typeGuard":"const isElementOrNull = (x) => x === null || (typeof Element !== 'undefined' && x instanceof Element);","tryCatchPattern":null,"preventionTips":["Use registerChild from WindowScroller's render prop attached to a DOM-resolving ref","Wrap custom children in React.forwardRef","Pass autoHeight to Grid/List inside WindowScroller"],"tags":["react","ref","windowscroller","dom-element"],"backgroundTag":"ref-not-dom-element","analyzedSha":"c737715486f724586aee8870ebea1e9efb7b0bfe","analyzedAt":"2026-08-30T00:33:38.249Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}