From 3f1cc77858f96dd13f81fca65c98f1bb11e1e8c7 Mon Sep 17 00:00:00 2001 From: melloware Date: Fri, 27 Oct 2023 08:32:27 -0400 Subject: [PATCH] Fix #5172: Ripple forwardRef issue --- components/lib/ripple/Ripple.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/lib/ripple/Ripple.js b/components/lib/ripple/Ripple.js index 7afacb8bae..a12e85141d 100644 --- a/components/lib/ripple/Ripple.js +++ b/components/lib/ripple/Ripple.js @@ -5,7 +5,7 @@ import { DomHandler, classNames, mergeProps } from '../utils/Utils'; import { RippleBase } from './RippleBase'; export const Ripple = React.memo( - React.forwardRef((inProps) => { + React.forwardRef((inProps, ref) => { const inkRef = React.useRef(null); const targetRef = React.useRef(null); const context = React.useContext(PrimeReactContext); @@ -72,6 +72,12 @@ export const Ripple = React.memo( } }; + React.useImperativeHandle(ref, () => ({ + props, + getInk: () => inkRef.current, + getTarget: () => targetRef.current + })); + useMountEffect(() => { if (inkRef.current) { targetRef.current = getTarget();