diff --git a/packages/react/src/ReactRenderer.tsx b/packages/react/src/ReactRenderer.tsx index f93ad7568..39e56e7c9 100644 --- a/packages/react/src/ReactRenderer.tsx +++ b/packages/react/src/ReactRenderer.tsx @@ -153,17 +153,19 @@ export class ReactRenderer = object> const isClassComp = isClassComponent(Component) const isForwardRefComp = isForwardRefComponent(Component) - if (!props.ref) { + const elementProps = { ...props } + + if (!elementProps.ref) { if (isReact19) { // React 19: ref is a standard prop for all components // @ts-ignore - Setting ref prop for React 19 compatibility - props.ref = (ref: R) => { + elementProps.ref = (ref: R) => { this.ref = ref } } else if (isClassComp || isForwardRefComp) { // React 18 and prior: only set ref for class components and forwardRef components // @ts-ignore - Setting ref prop for React 18 class/forwardRef components - props.ref = (ref: R) => { + elementProps.ref = (ref: R) => { this.ref = ref } } @@ -171,7 +173,7 @@ export class ReactRenderer = object> // This is a limitation we have to accept for React 18 function components without forwardRef } - this.reactElement = + this.reactElement = editor?.contentComponent?.setRenderer(this.id, this) }