Skip to content

Commit c452af2

Browse files
ildar-icoosoftdarthtrevino
andauthored
Update utils.tsx (#2488)
Co-authored-by: Chris Trevino <darthtrevino@users.noreply.github.com>
1 parent af84889 commit c452af2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/testing/test-utils/src/utils.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { Backend, DragDropManager } from 'dnd-core'
66
import { act } from 'react-dom/test-utils'
77

88
interface RefType {
9-
getManager: () => DragDropManager | undefined
9+
getManager: () => DragDropManager | undefined,
10+
getDecoratedComponent<T>(): T
1011
}
1112

1213
/**
@@ -19,9 +20,11 @@ export function wrapInTestContext(
1920
): any {
2021
const forwardedRefFunc = (props: any, ref: React.Ref<RefType>) => {
2122
const dragDropManager = React.useRef<any>(undefined)
23+
const decoratedComponentRef = React.useRef<any>(undefined)
2224

2325
React.useImperativeHandle(ref, () => ({
2426
getManager: () => dragDropManager.current,
27+
getDecoratedComponent: () => decoratedComponentRef.current
2528
}))
2629

2730
return (
@@ -32,7 +35,7 @@ export function wrapInTestContext(
3235
return null
3336
}}
3437
</DndContext.Consumer>
35-
<DecoratedComponent {...props} />
38+
<DecoratedComponent ref={decoratedComponentRef} {...props} />
3639
</DndProvider>
3740
)
3841
}

0 commit comments

Comments
 (0)