How to use public method updatePosition of react-virtualized?

人走茶凉 提交于 2019-11-29 16:28:44

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

It's right here and it has some unit tests too.

To use it you'll need to set a ref to WindowScroller. Here's a minimal example of what I mean:

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();
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!