How to use public method updatePosition of react-virtualized?

后端 未结 1 1729
無奈伤痛
無奈伤痛 2020-12-22 05:02

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

But I checkout the source: https://github.com/bvaughn/react-

相关标签:
1条回答
  • 2020-12-22 06:06

    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();
      }
    }
    
    0 讨论(0)
提交回复
热议问题