From 7e6b13a80d0c213fab264735798648f050105e39 Mon Sep 17 00:00:00 2001 From: Valeriia Maltseva Date: Mon, 2 Dec 2024 17:19:23 +0100 Subject: [PATCH] fixed issues --- .../components/drag-and-drop/draggable.tsx | 5 ++--- .../components/focal-point/focal-point.tsx | 22 +++++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/assets/js/src/core/components/drag-and-drop/draggable.tsx b/assets/js/src/core/components/drag-and-drop/draggable.tsx index b6f18ad24..78b572a4f 100644 --- a/assets/js/src/core/components/drag-and-drop/draggable.tsx +++ b/assets/js/src/core/components/drag-and-drop/draggable.tsx @@ -34,8 +34,7 @@ function Draggable (props: DraggableProps): React.JSX.Element | null { if (!isValidElement(Child)) { trackError(new GeneralError('Children must be a valid react component')) - - return null + throw new Error('Invalid React child element.') } const Component = Child.type @@ -51,7 +50,7 @@ function Draggable (props: DraggableProps): React.JSX.Element | null { { ...Child.props } /> - ), [[setNodeRef, listeners, attributes, Child.props, Component]]) + ), []) } const DraggableMemo = React.memo(Draggable) diff --git a/assets/js/src/core/components/focal-point/focal-point.tsx b/assets/js/src/core/components/focal-point/focal-point.tsx index e9027a586..e5f6c600c 100644 --- a/assets/js/src/core/components/focal-point/focal-point.tsx +++ b/assets/js/src/core/components/focal-point/focal-point.tsx @@ -46,8 +46,6 @@ export const FocalPoint = ({ activationConstraint, children }: FocalPointProps): if (focalPointContext === undefined) { trackError(new GeneralError('FocalPoint must be used within the FocalPointProvider')) - - return null } const { @@ -57,15 +55,7 @@ export const FocalPoint = ({ activationConstraint, children }: FocalPointProps): setIsActive, disabled, containerRef - } = focalPointContext - - if (!isValidElement(Image)) { - trackError(new GeneralError('Children must be a valid react component')) - - return null - } - - const ImageComponent = Image.type + } = focalPointContext! const onLoad = (): void => { if ( @@ -90,7 +80,15 @@ export const FocalPoint = ({ activationConstraint, children }: FocalPointProps): if (!isActive && !isLoading && containerRef.current !== null) { onToggleOff() } - }, [isActive, isLoading, containerRef]) + }, [isActive]) + + if (!isValidElement(Image)) { + trackError(new GeneralError('Children must be a valid react component')) + + return null + } + + const ImageComponent = Image.type return (