@@ -9,7 +9,7 @@ import withScrolling, {
99import isEqual from 'lodash.isequal'
1010import { DndContext , DndProvider } from 'react-dnd'
1111import { HTML5Backend } from 'react-dnd-html5-backend'
12- import { Virtuoso } from 'react-virtuoso'
12+ import { Virtuoso , VirtuosoHandle } from 'react-virtuoso'
1313import NodeRendererDefault from './node-renderer-default'
1414import PlaceholderRendererDefault from './placeholder-renderer-default'
1515import './react-sortable-tree.css'
@@ -185,7 +185,7 @@ class ReactSortableTree extends Component {
185185 constructor ( props ) {
186186 super ( props )
187187
188- this . listRef = React . createRef ( )
188+ this . listRef = props . virtuosoRef || React . createRef ( )
189189
190190 const { dndType, nodeContentRenderer, treeNodeRenderer, slideRegionSize } =
191191 mergeTheme ( props )
@@ -809,6 +809,11 @@ export type ReactSortableTreeProps = {
809809 // Class name for the container wrapping the tree
810810 className ?: string
811811
812+ // Ref for Virtuoso component
813+ // Use virtuosoRef when you wont to use virtuoso handler
814+ // (ex. scrollTo scrollToIndex)
815+ virtuosoRef ?: React . Ref < VirtuosoHandle >
816+
812817 // Style applied to the inner, scrollable container (for padding, etc.)
813818 innerStyle ?: any
814819
0 commit comments