Skip to content

Commit f3d82a3

Browse files
committed
Fix findDOMNode deprecation warning in slideshow widget
This warning is shown in the tests. Instead a ref is added to each element.
1 parent 2b3cbf2 commit f3d82a3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/ui/widgets/Slideshow/slideshow.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ export const SwitchableWidget = (props: {
3131
index: number;
3232
children: [ReactElement];
3333
transition: { readonly [key: string]: string };
34+
nodeRef: React.Ref<HTMLDivElement>;
3435
}): JSX.Element => {
36+
// react-transition-group internally uses findDOMNode which
37+
// is deprecated. Fix by passing nodeRef which points to the
38+
// transitioning child.
3539
return (
3640
<SwitchTransition mode="out-in">
3741
<CSSTransition
42+
nodeRef={props.nodeRef}
3843
classNames={props.transition}
3944
key={props.index}
4045
timeout={250}
@@ -69,6 +74,7 @@ export const SlideshowComponent = (
6974
const [transition, setTransition] = useState(slideRightTransition);
7075

7176
log.debug(`Slideshow Index: ${childIndex}`);
77+
const nodeRef = React.useRef<HTMLDivElement>(null);
7278

7379
return (
7480
<div
@@ -104,6 +110,7 @@ export const SlideshowComponent = (
104110
105111
</button>
106112
<div
113+
ref={nodeRef}
107114
style={{
108115
position: "relative",
109116
width: "80%",
@@ -114,7 +121,11 @@ export const SlideshowComponent = (
114121
overflow: props.overflow ?? ""
115122
}}
116123
>
117-
<SwitchableWidget index={childIndex} transition={transition}>
124+
<SwitchableWidget
125+
index={childIndex}
126+
transition={transition}
127+
nodeRef={nodeRef}
128+
>
118129
{props.children as [ReactElement]}
119130
</SwitchableWidget>
120131
</div>

0 commit comments

Comments
 (0)