的文档:https : //github.com/bvaughn/react- virtualized/blob/master/docs/WindowScroller.md#updateposition
但是我签出了源代码:https : //github.com/bvaughn/react- virtualized/blob/master/source/WindowScroller/WindowScroller.js
这不是公共方法,因此当其他元素大小更改时,如何使用此方法更新滚动位置?
但是我检查了源代码…这不是公共方法
这是在这里,它有一些单元测试过。
要使用它,您需要将ref设置为WindowScroller。这是我的意思的一个最小示例:
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(); } }