文档:https : //github.com/bvaughn/react-virtualized/blob/master/docs/WindowScroller.md#updateposition
但我查看了源代码:https : //github.com/bvaughn/react-virtualized/blob/master/source/WindowScroller/WindowScroller.js
它不是公共方法,那么当其他元素大小发生变化时,如何使用此方法更新滚动位置?
文档: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. 这是我的意思的最小示例:
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();
}
}