如何使用react-virtualized的public方法updatePosition?

How to use public method updatePosition of react-virtualized?

文档:https://github.com/bvaughn/react-virtualized/blob/master/docs/WindowScroller.md#updateposition

但我查看了来源:https://github.com/bvaughn/react-virtualized/blob/master/source/WindowScroller/WindowScroller.js

这不是 public 方法,所以当其他元素大小发生变化时,如何使用此方法更新滚动位置?

But I checkout the source...It's not a public method

right here and it has some unit tests too

要使用它,您需要将 ref 设置为 WindowScroller。这是我的意思的一个最小示例:

class YourComponent extends React.Component {
  render() {
    return (
      <WindowScroller
        ref={this._setRef}
        {...otherProps}
      />
    );
  }

  _setRef = ref => {
    this.windowScrollerRef = ref;
  }

  someOtherMethod() {
    // Assuming you've mounted, you can access public methods like:
    this.windowScrollerRef.updatePosition();
  }
}