Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit 85e10ac

Browse files
authored
Merge pull request #29 from azuharu07/add_props_virtuoso-ref
✏️ Add virtousoRef to ReactSortableTreeProps
2 parents 097d79f + fd70dd4 commit 85e10ac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/react-sortable-tree.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import withScrolling, {
99
import isEqual from 'lodash.isequal'
1010
import { DndContext, DndProvider } from 'react-dnd'
1111
import { HTML5Backend } from 'react-dnd-html5-backend'
12-
import { Virtuoso } from 'react-virtuoso'
12+
import { Virtuoso, VirtuosoHandle } from 'react-virtuoso'
1313
import NodeRendererDefault from './node-renderer-default'
1414
import PlaceholderRendererDefault from './placeholder-renderer-default'
1515
import './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

Comments
 (0)